Contents

SecItemDelete(_:)

Deletes items that match a search query.

Declaration

func SecItemDelete(_ query: CFDictionary) -> OSStatus

Parameters

  • query:

    A dictionary that describes the search for the keychain items you want to delete. A typical query dictionary 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 deleting, 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.

Mentioned in

Return Value

A result code. See Security Framework Result Codes.

Discussion

The query dictionary for delete can’t contain Item return result keys, because SecItemDelete(_:) only returns a status.

By default, this function deletes all items matching the specified query. You can change this behavior by specifying a key, as follows:

Performance considerations

SecItemDelete blocks the calling thread, so it can cause your app’s UI to hang if called from the main thread. Instead, call SecItemDelete from a background dispatch queue or async function: