---
title: "setDomain(_:)"
framework: securityinterface
role: symbol
role_heading: Instance Method
path: "securityinterface/sfchooseidentitypanel/setdomain(_:)"
---

# setDomain(_:)

Sets an optional domain in which the identity is to be used.

## Declaration

```swift
func setDomain(_ domainString: String!)
```

## Parameters

- `domainString`: A string containing a hostname, RFC 822 name (email address), URL, or similar identifier.

## Discussion

Discussion Call this method to associate a domain with the chosen identity. If the user chooses an identity and a domain is set, an identity preference item is created in the default keychain. Subsequent calls to  SecIdentitySearchCreate and SecIdentitySearchCopyNext return the preferred identity for this domain first.

## See Also

### Working with Domains

- [domain()](securityinterface/sfchooseidentitypanel/domain().md)
