Store authentication token in iPhone application
I want to store authentication token, that i received from log-in response.
It is right to use for this NSUserDefaults? Or I must use KeyChainWrapper?
What is the best way store authentication toke开发者_如何学编程n?
It is safer to store them in the Keychain (btw. https://github.com/ldandersen/scifihifi-iphone/tree/master/security is awesome).
@Akshay, NSUserDefaults is not the way to go at all... As soon as you delete the app from the iphone the NSUserDefaults entries get lost and won't be available after that again. KeyChain is much much safer for that kind of need.
Sebastian
Checkout SFHFKeychainUtils on GitHub:
[SFHFKeychainUtils storeUsername:aUsername andPassword:aPassword forServiceName:@"MyService" updateExisting:TRUE error:&anError];
there is also getPasswordForUsername
and deleteItemForUsername
edit- and cortez has provided link in his answer
NSUserDefaults
is the way to go. It is the simplest.
精彩评论