Iphone - Saving a password in keychain on simulator. Security at master from ldandersen/scifihifi-iphone - GitHub. Security/SFHFKeychainUtils.m at master from ldandersen/scifihifi-iphone - GitHub. Sci-Fi Hi-Fi — Simple iPhone Keychain Code. I’ve had occasion to work with Apple’s Keychain security APIs a couple times now (once while developing Cocoalicious, and now for a few iPhone projects I’m working on), and, in terms of complexity of use relative to simplicity of the task at hand, I think it has to be about the worst API I’ve ever encountered.
I’m sure it’s infinitely flexible and capable of doing all kinds of crazy stuff that my non-Lone Gunman brain doesn’t even begin to comprehend, but for me (and I’m guessing 90% of application developers out there), all it really needs to do is let me store a password safely and retrieve it later. Now, it would be one thing if Keychain lacked an intuitive API but at least provided good sample code, but to my mind much of Apple’s relevant sample code, including the GenericKeychain sample app in Apple’s iPhone Developer Program portal, is fairly obfuscated and does little to easily illuminate how a user of the API would accomplish common, concrete tasks.
Management of User name & Password and KeyChain(SFHFKeychainUtils)_做事. Management of User name & password is a extremely common issue in Development process of iPhone App dev. Every time when I create a new project, I must to consider this issue, and now, I post some tips about this here: Usually, I save/retrieve the data with User defaults object like this: [[NSUserDefaults standardUserDefaults] stringForKey:@"kUserName"]; [[NSUserDefaults standardUserDefaults] stringForKey:@"kPassword"]; But there's a amazing utility for this job in fact! SFHFKeychainUtils ! You can fetch it by doing this: git clone What you need to do is simple adding the SFHFKeychainUtils.h and SFHFKeychainUtils.m into your project and use it like this: NSString *username = [[NSUserDefaults standardUserDefaults] stringForKey:@"kUserName"]; NSString *password = (username ?
[SFHFKeychainUtils getPasswordForUsername:username andServiceName:@"Your customed service name" error:&error] : nil); if (! [alert show]; Ios4 - Error saving in the keychain with iphone sdk.