【发布时间】:2011-05-17 14:01:09
【问题描述】:
我使用Apple wraper for the keychain,并尝试在上面保存一个项目(在模拟器中运行,ios 4.1)。
我以前没有使用过钥匙串。
我收到此错误:
无法添加钥匙串项。错误 - 25299
在 KeychainItemWrapper.m 第 304 行:
// No previous item found; add the new one.
result = SecItemAdd((CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL);
NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
我就是这样保存的:
- (void) saveKey:(NSString *)key value:(NSString *)value {
KeychainItemWrapper *keyItem = [[KeychainItemWrapper alloc] initWithIdentifier:key accessGroup:nil];
[keyItem setObject:value forKey:(id)kSecValueData];
[keyItem release];
}
这是 api 尝试保存的值:
<CFBasicHash 0x7231f60 [0x320d380]>{type = mutable dict, count = 5,
entries =>
2 : <CFString 0x2e6eb98 [0x320d380]>{contents = "labl"} = <CFString 0x2fb018 [0x320d380]>{contents = ""}
3 : <CFString 0x2e6efb8 [0x320d380]>{contents = "v_Data"} = <CFString 0x727de60 [0x320d380]>{contents = "dit8"}
4 : <CFString 0x2e6ebc8 [0x320d380]>{contents = "acct"} = <CFString 0x2fb018 [0x320d380]>{contents = ""}
5 : <CFString 0x2e6eb58 [0x320d380]>{contents = "desc"} = <CFString 0x2fb018 [0x320d380]>{contents = ""}
6 : <CFString 0x2e6ebe8 [0x320d380]>{contents = "gena"} = <CFString 0x2ffd08 [0x320d380]>{contents = "userCode"}
}
【问题讨论】:
-
我一直坚持这一点,所以我认为赏金是个好主意。相同的errorCode但iOS4.3但我猜这是PEBKAC问题,sdk没有问题。
-
我在
- (void)resetKeychainItem中添加[keychainItemData setObject:@"" forKey:(__bridge id)kSecAttrService];时出现了这个问题。然后,当我在下面阅读 user379075 的答案时,它响起一个铃声,如果你“重置”它,你还必须设置它和 v.v.