0

First: I am aware that there are other questions regarding the KeychainItemWrapper already posted. I read them all, but I did not succeed with what should be a really simple task: storing a value in the Keychain (on the device, not simulator). I always get an assertion failure, "Couldn't add the Keychain Item".

Here is my code, I want to get an uuid, and, if not existing, create and store one:

+ (NSString *)getDeviceID{
KeychainItemWrapper * keychain = [[[KeychainItemWrapper alloc]initWithIdentifier:KEYCHAIN_ID accessGroup:nil]autorelease];
NSString * uuid = [keychain objectForKey:KEYCHAIN_ID];
if ( uuid == nil ){
    uuid = [self createDeviceID];
    [keychain setObject:uuid forKey:@"UUID"];
}
return uuid;
}

I just can't figure it out.

1 Answers1

0
+ (NSString *)getDeviceID
{
    KeychainItemWrapper * keychain = [[KeychainItemWrapper alloc] initWithIdentifier:KEYCHAIN_ID accessGroup:nil];
    NSString * uuid = [keychain objectForKey:(__bridge id)kSecAttrLabel];

    if ( uuid == nil )
    {
        uuid = [self createDeviceID];
        [keychain setObject:uuid forKey:(__bridge id)kSecAttrLabel];
    }
    return uuid;
}

(_bridge id)kSecAttrLabel can be (_bridge id)kSecAttrDescription

Dimentar
  • 603
  • 7
  • 13