Keychain Item包装器给出BAD_ACCESS_CODE = 2

时间:2013-10-24 04:25:13

标签: ios keychainitemwrapper

我想将自己的应用状态保留在钥匙串中。所以我必须这样做

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

但在这一行中,它在以下行中得到EXC_BAD_ACCESS_Code=2 - 在我的Viewcontroller中 -

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

-in KeychainItemWrapper.m -

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

 [self writeToKeychain];

1 个答案:

答案 0 :(得分:0)

我想您在setObjectsetValue之间感到困惑,请将设置更改为:

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