Searching for Items

Attribute lists are used in three ways:

  1. to specify a search for items.

  2. to read data from an item.

  3. to set the data for an item.

For example, to create a search for all generic passwords that have bignerdranch as the account name, you would create an attribute list and invoke SecKeychainSearchCreateFromAttributes().

OSStatus SecKeychainSearchCreateFromAttributes (CFTypeRef  keychainOrArray,
                                             SecItemClass  itemClass, 
                           const SecKeychainAttributeList *attrList, 
                                     SecKeychainSearchRef *searchRef);

Most of the functions in the Security framework deal well with NULLs. They do what you would hope. For example, if you pass NULL as the first argument, the search will check all the user’s normal keychains. Usually, this is what you want. For the ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.