我正在存儲和加載序列化的nsdictionary到鑰匙串中(Store NSDictionary in keychain),但我需要能夠更新/編輯字典內容,所以我想刪除它並重新添加。如何從鑰匙串中刪除nsdictionary替換
我只是不知道該怎麼做。我從以上帖子中獲取以下代碼:
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"arbitraryId" accessGroup:nil]
NSString *error;
//The following NSData object may be stored in the Keychain
NSData *dictionaryRep = [NSPropertyListSerialization dataFromPropertyList:dictionary format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
[keychain setObject:dictionaryRep forKey:kSecAttrService];
//When the NSData object object is retrieved from the Keychain, you convert it back to NSDictionary type
dictionaryRep = [keychain objectForKey:kSecAttrServce];
NSDictionary *dictionary = [NSPropertyListSerialization propertyListFromData:dictionaryRep mutabilityOption:NSPropertyListImmutable format:nil errorDescription:&error];
SecItemDelete((CFDictionaryRef)dictionaryRep); // doesnt work
這些值不會從鑰匙串中刪除。
謝謝