NitroKeychain is a thin, yet powerful, abstraction layer on top of iOS keychain that provides commonly needed features. NitroKeychain is also thread safe.
There are 3 operations: save
, load
and delete
, as you can see below:
[TNTKeychain save: @"com.myapp.service.id"
data: @"my-ultra-secret-token"];
// Or, if you want to make this item available across apps, specify
// an access group:
[TNTKeychain save: @"com.myapp.service.id"
data: @"my-ultra-secret-token"
accessGroup: @"super-company"];
TNTKeychain.save("com.myapp.service.id", data: "my-ultra-secret-token")
// Or, if you want to make this item available across apps, specify
// an access group:
TNTKeychain.save("com.myapp.service.id",
data: "my-ultra-secret-token",
accessGroup: "super-company")
- All keychain items are stored using the kSecClassGenericPassword Keychain Item class.
data
can be any value compatible withNSKeyedArchiver
/NSKeyedUnarchiver
.- If there is already some data associated with a keychain item ID, it will be updated.
NSString *token = [TNTKeychain load: @"com.myapp.service.id"];
NSLog( @"%@", token );
load
will returnnil
if no keychain item is found with such id.
let token = TNTKeychain.load("com.myapp.service.id")
print(token)
[TNTKeychain delete: @"com.myapp.service.id"];
delete
does nothing if no keychain item is found with such id.
TNTKeychain.delete("com.myapp.service.id")
Simple as that 👍
iOS 6.0 or higher, ARC only
NitroKeychain is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NitroKeychain'
NitroKeychain is available under the MIT license. See the LICENSE file for more info.