To save user credentials, I would suggest using the KeychainItemWrapper class from apple:
You use it to save such values ββ(e.g. with email / password text fields)
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"myAppLogin" accessGroup:nil]; [keychainItem setObject:txtPassword.text forKey:(__bridge id)(kSecValueData)]; [keychainItem setObject:txtEmail.text forKey:(__bridge id)(kSecAttrAccount)]; }
And then when you want to get the values ββback from the keychain, you simply:
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"myAppLogin" accessGroup:nil]; NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc]init]; [myDictionary setObject:[keychainItem objectForKey:(__bridge id)(kSecAttrAccount)] forKey:@"email"]; [myDictionary setObject:[keychainItem objectForKey:(__bridge id)(kSecValueData)] forKey:@"password"];
Also, be sure to download KeychainItemWrapper.h and .m from the developer.apple.com link I posted on top :)
So yes, basically explained what Steve said :)
source share