I"m saving my user email id, password and auth token in keychain. Sometimes, the password text alone drops a character, but others doesn't. I couldn't figure out what is causing this problem. Initially I had these saved in NSUserDefaults and the same thing happened. I thought moving to keychain would fix this issue. But it didn't. I have wasted days trying to figure this out. Any help will really be appreciated.
This is how I'm saving:
[keychainItem setObject:userEmailId forKey:(__bridge id)kSecAttrAccount];
[keychainItem setObject:userPassword forKey:(__bridge id)kSecValueData];
and retrieving the password.
NSData *password =[keychainItem objectForKey:(__bridge id)(kSecValueData)];
userPassword = [[NSString alloc] initWithData:password encoding:NSUTF8StringEncoding];
NSLog(@"Password from keychain = %@ and textfield = %@",userPassword,txtPassword.text);
userEmailId = [keychainItem objectForKey:(__bridge id)kSecAttrAccount];
The userPassword or txtPassword.text is never being accessed or changed anywhere else.