繁体   English   中英

iOS移除钥匙串价值

[英]iOS Remove Keychain Value

我像这样使用钥匙串:

KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"LoginData" accessGroup:nil];
[keychain setObject:responseObject[@"TOK"] forKey:CFBridgingRelease(kSecAttrAccount)];

并希望像这样删除(使值无效):

[keychain setValue:nil forKey:CFBridgingRelease(kSecAttrAccount)];

但是,我只看到以下内容:

setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key acct.

就像明智的,当我使用这个:

[keychain setNilValueForKey:CFBridgingRelease(kSecAttrAccount)];

我得到这个:

setNilValueForKey]: could not set nil as the value for the key acct.

我正在使用苹果的KeychainItemWrapper,我该如何正确执行?

通常,要删除项目,请生成通常要提取的查询,然后使用“ SecItemDelete”。

像这样 -

    NSMutableDictionary *query = [self getQueryForKey:key];
OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
if( status != errSecSuccess) {
    ...
}

如果您使用的是keyChainWrapper,则可以-

    KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"LoginData" accessGroup:nil];
    [keychain resetKeychainItem];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM