I wanna save UUID in keychain with KeychainItemWrapper, so I add the following methods in MyKeychainManager.m :
#define keychain_idenentify @"com.myapp.bundle1"
+ (void)saveUUID:(NSString *)UUID{
if([MyKeychainManager getUUID].length > 0) {
return;
}
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc]initWithIdentifier:keychain_idenentify accessGroup:nil];
[keychain setObject:UUID forKey:(__bridge id)kSecAttrLabel];
}
+ (NSString *)getUUID {
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc]initWithIdentifier:keychain_idenentify accessGroup:nil];
NSString *uuidString = [keychain objectForKey:(__bridge id)kSecAttrLabel];
return uuidString;
}
But after I change the keychain_idenentify to com.otherApp.bundle, it crashed at
result = SecItemAdd((CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL); NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
and the error is Error - 25299
Why is this and how to solve this? Which I should choose such as kSecAttrLabel? I changed it to kSecAttrService it works fun but I don't know is there any other potential bugs.
Any help will be appreciate.