---
title: "SecKeychainSetDomainDefault(_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/seckeychainsetdomaindefault(_:_:)"
---

# SecKeychainSetDomainDefault(_:_:)

Sets the default keychain for a specified preference domain.

## Declaration

```swift
func SecKeychainSetDomainDefault(_ domain: SecPreferencesDomain, _ keychain: SecKeychain?) -> OSStatus
```

## Parameters

- `domain`: The preference domain for which you wish to set the default keychain. See doc://com.apple.security/documentation/Security/SecPreferencesDomain for possible domain values.
- `keychain`: A reference to the keychain you wish to set as default in the specified preference domain.

## Return Value

Return Value A result code. See Security Framework Result Codes.

## Discussion

Discussion A preference domain is a set of security-related preferences, such as the default keychain and the current keychain search list. Use this function if you want to set the default keychain for a specific preference domain. Use the SecKeychainSetDefault(_:) function if you want to set the default keychain for the current preference domain. See the SecKeychainSetPreferenceDomain(_:) function for a discussion of current and default preference domains.
