views:

477

answers:

2

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.

+2  A: 

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];

Note that by convention, when you get back an NSError you need to release it yourself (they do not come back autoreleased).

Kendall Helmstetter Gelner
I mean, I understand the function calls, it's just I'm not exactly sure how to use the interface (files in the UI folder) he includes.
Apophenia Overload
The example I posted stores a password for fred, and then retrieves it...
Kendall Helmstetter Gelner
I understand, but I'm unsure how to use the files used in the UI folder in order to create the nib. The methods I actually understand. Is there a sample project for this anywhere?
Apophenia Overload
I think you need to work through the tutorials on creating iPhone apps, you seem to be trying to run before you can walk... there's no nib at all involved in using this library, if you can't use it from the sample above you need to study how projects and XCode work more generally.
Kendall Helmstetter Gelner
Then what are the files in the UI folder for, then?
Apophenia Overload
No clue since I didn't use them in the project where I used that library. Probably some kind of default login page. Again if you work through a few tutorials you can easily scan the project and see what parts make sense for you to use. If you can't figure out how to use the code from what I posted the chances of making a working app are slim, you must understand more of how the parts of the iPhone SDK relate.
Kendall Helmstetter Gelner
@Kendall, I edited a possible typo (`MyService` -> `myService` that @Eran mentions in a separate answer), but if you intended it that way, feel free to revert.
Jesse Beder
+1  A: 

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.

Eran