Editing the Keychain

With the item, you can also make changes using an attribute list:

OSStatus SecKeychainItemModifyContent (SecKeychainItemRef  itemRef,
                           const SecKeychainAttributeList *attrList, 
                                                   UInt32  newPasswordLength, 
                                               const void *newPassword)

The new attribute values would go into the attrList. A new password would go into newPassword.

To delete an item:

OSStatus SecKeychainItemDelete (SecKeychainItemRef itemRef)

Note that you would still have to call CFRelease() on the item to prevent a memory leak.

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.