How to Store Username and password in Keychain and verify them through alertView

Solutions Collect From Internet About “How to Store Username and password in Keychain and verify them through alertView”

NSString *username = @"yourUserName";
NSString *password = @"yourPassword";
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"TestAppLoginData" accessGroup:nil];

// Store username to keychain
[keychain setObject:username forKey:(id)kSecAttrAccount];

// Store password to keychain
[keychain setObject:password forKey:(id)kSecValueData]; 


// Get username from keychain (if it exists)
NSString *username = [keychain objectForKey:(id)kSecAttrAccount];
NSLog(@"username: %@", username);


// Get password from keychain (if it exists)  
NSString *password = [keychain objectForKey:(id)kSecValueData];
NSLog(@"password: %@", password);

Download KeychainItemWrapper form here