开发者_运维问答Is there a way I can purge the keychain for my iphone app? Either a purge command or a listing of all keys so I can delete them myself.
There is no such thing as purge command.
Anyway since the keychain your application has access to is dedicated for your application only you can easily keep track of what you have written in it and delete it.
You can implement your own purge method that will simply delete one by one all possible data types that you can save in keychain. Below is how I purge all my GenericPassword entries:
- (BOOL)deleteKeychainData
{
/* delete custom data */
NSMutableDictionary *searchData = [NSMutableDictionary new];
[searchData setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
[searchData setObject:kTagKeychainService forKey:(id)kSecAttrService];
OSStatus statusData = SecItemDelete((CFDictionaryRef)searchData);
[searchData release];
CHECK_CONDITION1(statusData == errSecSuccess
|| statusData == errSecItemNotFound,
@"Error while deleting keychain data, OSStatus == %d", statusData);
/* delete assymetric keys*/
return [self deleteKeyPair];
}
So what you need to do is call this method for all possible kSecClass values.
NOTE that different data types would require different dictionary flags to be set.
regards
精彩评论