Good afternoon,
I'm trying to store username and password using Keychain (in order to access that data later in my ProfileViewController) and I'm a little bit lost because it's my first time using Keychain and the Apple documentation is so big and confusing and I can't find a good example or tutorial to follow with a simple username and password stored and read from another ViewController.
Can you help me with that? Can you show me some example or a good tutorial to learn and follow that?
I have already imported the security framework, but now I don't know which file I have to add to my project to go on with the Keychain.
Thanks in advance.
I recommend this wrapper for the Keychain, SSKeychain. Once you have that added to your project, all you need to call in your code is:
Get a password:
NSString *usersPassword = [SSKeychain passwordForService:@"login" account:@"account"];
Set a password:
NSString *enteredPassword = self.passworldField.text;
[SSKeychain setPassword:enteredPassword forService:@"login" account:@"account"];