Question

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];
Was it helpful?

Solution

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

[keychainItemLog setObject:(__bridge id)(kSecValueData) forKey:@"STATUS"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top