0

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.

LoveMeSomeFood
  • 3,137
  • 7
  • 30
  • 53
  • are you verified the condition or not – Anbu.Karthik Nov 04 '15 at 16:34
  • @Anbu.Karthik Sorry I dont get what you are saying – LoveMeSomeFood Nov 04 '15 at 17:29
  • It seems that there is something somewhere in your code that is removing a character from the password. Try following the path of the passcode all the way from input through saving and then onto loading and see if you can find it. Also it may help to add print() functions to print the password to the console at multiple points in the path of the password to help pinpoint where the error is. It would help greatly if you were to post your code, at least just the code that is being used to save and load the data. – Stewart Hering Nov 04 '15 at 19:10
  • @StewartHering Sure. I will try that and add the code here – LoveMeSomeFood Nov 04 '15 at 19:19

0 Answers0