钥匙扣正在ios中重置

时间:2014-07-11 15:55:10

标签: ios keychainitemwrapper

我使用keychain类在keychain中存储一些值。通过使用这些钥匙串默认方法

KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:@"identifier" accessGroup:nil];

 [item setObject:@"some_value" forKey:(id)kSecAttrService];
[item setObject:@"Some_value" forKey:(id)kSecValueData];

值正在钥匙串中成功保存 当我关闭应用程序并再次启动它并初始化keychain对象

then this  condition in this function of keychain

- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup`

是正确的,因为我的密钥正在重置并且没有返回值

    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];

        }
    }

原因是这些方法返回nil

[item objectForKey:(id)kSecAttrService];
[item objectForKey:(id)kSecValueData];

我不明白,当第一次保存价值时,为什么会出现这种情况。

任何人都可以帮助我

thankss

0 个答案:

没有答案