SecItemUpdate(_:_:)
Modifies items that match a search query.
Declaration
func SecItemUpdate(_ query: CFDictionary, _ attributesToUpdate: CFDictionary) -> OSStatusParameters
- query:
A dictionary that describes the search for the keychain items you want to update. A typical
querydictionary consists of:The item’s class. Specify the kind of item you want, for example a password, a certificate, or a cryptographic key, using one of the class values in Item Class Keys And Values.
Attributes. Narrow the search by indicating the attributes that the found item or items should have. The more attributes you specify, the more refined the results, but not all attributes apply to all item classes. For the attributes applicable to the keychain item you’re updating, see the entry for the item’s class in Item Class Keys And Values.
Search parameters. Condition the search in a variety of ways. For example, you can limit the results to a specific number of items, control case sensitivity when matching string attributes, or search only among a particular set of items. See Search Attribute Keys And Values for the complete list of possible search parameters.
- attributesToUpdate:
A dictionary containing the attributes whose values should update, along with the new values. Only real keychain attributes are permitted in this dictionary (no “meta” attributes are allowed.) For the attributes applicable to the keychain item you’re updating, see the entry for the item’s class in Item Class Keys And Values.
Mentioned in
Return Value
A result code. See Security Framework Result Codes.
Discussion
The query dictionary for update can’t contain Item return result keys, because SecItemUpdate(_:_:) only returns a status.
Performance considerations
SecItemUpdate blocks the calling thread, so it can cause your app’s UI to hang if called from the main thread. Instead, call SecItemUpdate from a background dispatch queue or async function: