sqreept sqreept - 2 months ago 8x
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?


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);