Reading Data From an Item

Of course, once you have fetched the item, you can do all sorts of nifty things with it. For example, if you wanted to read the password, the account name, the description, and the modification date from an item, you would create an attribute list containing those attributes and call SecKeychainItemCopyContent():

OSStatus SecKeychainItemCopyContent (SecKeychainItemRef  itemRef,
                                           SecItemClass *itemClass, 
                               SecKeychainAttributeList *attrList,
                                                 UInt32 *length, 
                                                   void **outData);

Note that here the attrList is specifying what data you want and is also acting as a receptacle. Add these functions to dumpem.m:

/​/​ ​G​i​v​e​n​ ​a​ ​c​a​r​b​o​n​-​s​t​y​l​e​ ​f​o​u​r​ ​c​h​a​r​a​c​t​e​r​ ​c​o​d​e​,​ ​m​a​k​e​ ​a​ ​C​ ​s​t​r​i​n​g​ ...

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.