<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SecurityInterface",
  "identifier" : "/documentation/SecurityInterface/SFChooseIdentityPanel/setDomain(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Security Interface"
    ],
    "preciseIdentifier" : "c:objc(cs)SFChooseIdentityPanel(im)setDomain:"
  },
  "title" : "setDomain(_:)"
}
-->

# setDomain(_:)

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

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

## Parameters

`domainString`

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

## 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  <doc://com.apple.documentation/documentation/Security/SecIdentitySearchCreate> and <doc://com.apple.documentation/documentation/Security/SecIdentitySearchCopyNext> return the preferred identity for this domain first.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)