3

I want to keep my app status in keychain. So I have to put like this

KeychainItemWrapper *keychainItemLog = [[KeychainItemWrapper alloc] initWithIdentifier:@"LoggedORNOT" accessGroup:nil];
[keychainItemLog setObject:@"STATUS" forKey:(__bridge id)(kSecValueData)];
 keychainItemLog setObject:@"TOVERIFY" forKey:(__bridge id)(kSecAttrAccount)];

But in this line its getting EXC_BAD_ACCESS_Code=2 in following lines - in my Viewcontroller-

[keychainItemLog setObject:@"STATUS" forKey:(__bridge id)(kSecValueData)];

-in KeychainItemWrapper.m -

NSAssert( result == noErr, @"Couldn't add the Keychain Item." );

and

 [self writeToKeychain];
Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71
user2889249
  • 899
  • 2
  • 13
  • 22

1 Answers1

0

I guess you are confusing between setObject and setValue, change your setting as below:

[keychainItemLog setObject:(__bridge id)(kSecValueData) forKey:@"STATUS"];
Tarek Hallak
  • 18,422
  • 7
  • 59
  • 68
  • Not sure I got your question but you just need to switch between the value and the key, @"STATUS" supposed to be the key, and `kSecValueData` is the value. – Tarek Hallak Oct 24 '13 at 05:14
  • If the key is `NSString` then it works, but you need to understand that you will get the value by the key you gave, I suggest to double check the other places ;). – Tarek Hallak Oct 24 '13 at 05:23