<!--
{
  "availability" : [
    "macOS: 10.2.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeychainItemSetAccess(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecKeychainItemSetAccess"
  },
  "title" : "SecKeychainItemSetAccess(_:_:)"
}
-->

# SecKeychainItemSetAccess(_:_:)

Sets the access of a given keychain item.

```
func SecKeychainItemSetAccess(_ itemRef: SecKeychainItem, _ access: SecAccess) -> OSStatus
```

## Parameters

`itemRef`

A keychain item.

`access`

An access instance to replace the keychain item’s current access instance. Use the [`SecAccessCreate(_:_:_:)`](/documentation/Security/SecAccessCreate(_:_:_:)) function to create a default access instance.

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes).

## Discussion

Use this function to attach an access instance to a particular keychain item. Alternatively, you can use the [`kSecAttrAccess`](/documentation/Security/kSecAttrAccess) attribute when calling either of the [`SecItemAdd(_:_:)`](/documentation/Security/SecItemAdd(_:_:)) or [`SecItemUpdate(_:_:)`](/documentation/Security/SecItemUpdate(_:_:)) methods.

---

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)