sqreept sqreept - 1 year ago 82
Objective-C Question

How to delete all keychain items accessible to an app?

I have stray keychain items on iOS (probably written by old version of app) that I need to delete. Is there an easy way to achieve this?

Answer Source

do it for all classes

NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword,
                       (__bridge id)kSecClassInternetPassword,
                       (__bridge id)kSecClassCertificate,
                       (__bridge id)kSecClassKey,
                       (__bridge id)kSecClassIdentity];
for (id secItemClass in secItemClasses) {
    NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
    SecItemDelete((__bridge CFDictionaryRef)spec);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download