问题
You can find it here.
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.
回答1:
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];
回答2:
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.
来源:https://stackoverflow.com/questions/1870000/has-anyone-used-buzz-andersens-simple-iphone-keychain-code