Has anyone used Buzz Andersen's Simple iPhone Keychain code?
-
18-09-2019 - |
Question
I'm trying to understand his sample code in order to write a simple program with that stores passwords into the keychain and retrieves them for login. Has anyone done this before? It would be most appreciated if I can see any examples you may have.
Solution
There's really no code to demonstrate, he lists both calls there.
Heres's an example, for what it is worth:
NSError *error;
[SFHFKeychainUtils storeUsername:@"fred" andPassword:@"mypassword123" forServiceName:@"myService" updateExisting:YES error:&error];
NSString *storedPassword = [SFHFKeychainUtils getPasswordForUsername:@"fred" andServiceName:@"myService" error:&error];
OTHER TIPS
To other newbies that use this code as is and don't understand why it doesn't work. Notice that the ServiceName is different (First without capital - "myService" and second with capital: "MyService"), that's why it doesn't work. Make the ServiceName the same.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow