Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way to remove(purge) all keychain data for an iOS app

I stored some information in the keychain, and there is a case that I need to remove all of the items, instead of doing [keychain removeObjectForKey:theKey] for all the keys, can I do:

NSDictionary *spec = [NSDictionary dictionaryWithObjectsAndKeys:(id)kSecClassGenericPassword, kSecClass,
                      [self serviceName], kSecAttrService, nil];

return !SecItemDelete((CFDictionaryRef)spec);

instead?

I tried it and it worked, just not sure if I am doing the correct thing?

like image 408
hzxu Avatar asked Mar 06 '13 01:03

hzxu


1 Answers

in my app I'm using this line to clear my keychain :

[[[KeychainItemWrapper alloc] initWithIdentifier:@"my_key" accessGroup:nil] resetKeychainItem]
like image 59
Kirualex Avatar answered Sep 29 '22 08:09

Kirualex