Inherits from NSObject
Declared in KeychainWrapper.h

Overview

KeychainWrapper simple wrapper around the secure keychain

requires the security framework

Tasks

Searching for values in Keychain

Create, update or Delete Keychain items

Class Methods

createKeychainValue:forIdentifier:

Default initializer to store a value in the keychain. Associated properties are handled for you – setting Data Protection Access, Company Identifer (to uniquely identify string, etc).

+ (BOOL)createKeychainValue:(NSString *)value forIdentifier:(NSString *)identifier

Parameters

value

value to set

identifier

key for the stored item

Declared In

KeychainWrapper.h

createKeychainValue:forIdentifier:withDescription:

Stores a value and a description to the keychain

+ (BOOL)createKeychainValue:(NSString *)value forIdentifier:(NSString *)identifier withDescription:(NSString *)description

Parameters

value

value to set

identifier

key for the stored item

description

a text description of the parameter

Discussion

descriptions are really only useful in OSX, since under IOS there is no way to browse the keychain like there is under OSX. You can set it but there is no way to see it afterwards.

Declared In

KeychainWrapper.h

deleteItemFromKeychainWithIdentifier:

Delete a value in the keychain.

+ (void)deleteItemFromKeychainWithIdentifier:(NSString *)identifier

Parameters

identifier

key for the stored item

Declared In

KeychainWrapper.h

keychainStringFromMatchingIdentifier:

Calls searchKeychainCopyMatchingIdentifier: and converts to a string value.

+ (NSString *)keychainStringFromMatchingIdentifier:(NSString *)identifier

Parameters

identifier

key for the stored item

Declared In

KeychainWrapper.h

searchKeychainCopyMatchingIdentifier:

Generic exposed method to search the keychain for a given value. Limit one result per search.

+ (NSData *)searchKeychainCopyMatchingIdentifier:(NSString *)identifier

Parameters

identifier

key for the stored item

Declared In

KeychainWrapper.h

updateKeychainValue:forIdentifier:

Updates a value in the keychain. If you try to set the value with createKeychainValue: and it already exists, this method is called instead to update the value in place.

+ (BOOL)updateKeychainValue:(NSString *)value forIdentifier:(NSString *)identifier

Parameters

value

value to set

identifier

key for the stored item

Declared In

KeychainWrapper.h