I am using keychain class for storing some value in keychain . By using these keychain default methods
KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:@"identifier" accessGroup:nil];
[item setObject:@"some_value" forKey:(id)kSecAttrService];
[item setObject:@"Some_value" forKey:(id)kSecValueData];
values is being saved successfully in keychain When I close app and start it again and initialize keychain object
then this condition in this function of keychain
- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup`
is being true, cause of that my key is being reset and returns no value
if (! SecItemCopyMatching((CFDictionaryRef)tempQuery, (CFTypeRef *)&outDictionary) == noErr)
{
// Stick these default values into keychain item if nothing found.
[self resetKeychainItem];
// Add the generic attribute and the keychain access group.
[keychainItemData setObject:identifier forKey:(id)kSecAttrGeneric];
if (accessGroup != nil)
{
// Ignore the access group if running on the iPhone simulator.
//
// Apps that are built for the simulator aren't signed, so there's no keychain access group
// for the simulator to check. This means that all apps can see all keychain items when run
// on the simulator.
//
// If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the
// simulator will return -25243 (errSecNoAccessForItem).
[keychainItemData setObject:accessGroup forKey:(id)kSecAttrAccessGroup];
}
}
cause of that these methods return nil
[item objectForKey:(id)kSecAttrService];
[item objectForKey:(id)kSecValueData];
I don't understand , when value are saved first time then why this condition is being true.
can anybody help me
thankss