Inherits from NSObject
Declared in DTKeychain.h

Overview

Wrapper for the iOS/OSX keychain

Class Methods

sharedInstance

The shared instance of DTKeychain

+ (instancetype)sharedInstance

Declared In

DTKeychain.h

Instance Methods

keychainItemsMatchingQuery:error:

Query the keychain for items matching the query

- (NSArray *)keychainItemsMatchingQuery:(NSDictionary *)query error:(NSError *__autoreleasing *)error

Parameters

query

The query to find certain keychain items

error

An optional output parameter to take on an error if one occurs

Return Value

An array of results or nil if the query failed

Declared In

DTKeychain.h

removeKeychainItem:error:

Removes a keychain item from the keychain

- (BOOL)removeKeychainItem:(DTKeychainItem *)keychainItem error:(NSError *__autoreleasing *)error

Parameters

keychainItem

The DTKeychainItem to remove from the keychain

error

An optional output parameter to take on an error if one occurs

Return Value

YES if the operation was successful

Declared In

DTKeychain.h

removeKeychainItems:error:

Removes multiple keychain items from the keychain

- (BOOL)removeKeychainItems:(NSArray *)keychainItems error:(NSError *__autoreleasing *)error

Parameters

keychainItems

The keychain items to remove from the keychain

error

An optional output parameter to take on an error if one occurs

Return Value

YES if the operation was successful

Declared In

DTKeychain.h

retrieveSecuredDataForKeychainItem:error:

On OSX the secure data of keychain items needs to be retrieved separately whereas on iOS keychainItemsMatchingQuery:error: already does that. On OSX this triggers a user interaction alert asking the user to permit access for items which have not been created by the current app.

- (BOOL)retrieveSecuredDataForKeychainItem:(DTKeychainItem *)keychainItem error:(NSError *__autoreleasing *)error

Parameters

keychainItem

The DTKeychainItem for which to retrieve the secure data

error

An optional output parameter to take on an error if one occurs

Return Value

YES if the operation was successful

Declared In

DTKeychain.h

writeKeychainItem:error:

Writes the keychain item to the keychain. If it has a persistent reference it will be an update, if not it will be newly created.

- (BOOL)writeKeychainItem:(DTKeychainItem *)keychainItem error:(NSError *__autoreleasing *)error

Parameters

keychainItem

The DTKeychainItem to persist

error

An optional output parameter to take on an error if one occurs

Return Value

YES if the operation was successful

Declared In

DTKeychain.h