保存鑰匙鏈時出錯使用Apple wraper for the keychain,並嘗試保存一個項目(在模擬器中運行,ios 4.1)。使用iphone sdk
我還沒有使用鑰匙扣的經驗。
我得到這個錯誤:
Couldn't add the Keychain Item. Error - 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"}
}
你解決了這個問題嗎? – 2011-04-07 20:28:31
我被這個困住了,所以我認爲賞金是個好主意。相同的errorCode,但iOS4.3但我想這是一個PEBKAC問題,並沒有與sdk的問題。 – 2011-04-07 20:37:56
當我在` - (void)resetKeychainItem`中添加`[keychainItemData setObject:@「」forKey:(__ bridge id)kSecAttrService];`時,發生了此問題。然後,當我在閱讀下面的user379075的答案時,它響起了一個鐘聲,如果你「重置」它,你還必須設置它和v.v. – mrd3650 2012-04-13 15:52:37