How do you reset an iPhone App's Keychain?

前端 未结 4 1653
清酒与你
清酒与你 2020-12-13 06:44

I would like to know if there is a way to reset my app\'s Keychain. I am wondering whether anything like [NSUserDefaults resetStandardUserDefaults] exists for k

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 07:40

    KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"nameOfYourKeychain" accessGroup:nil];
    
    [keychainItem resetKeychainItem];
    

    Much simpler :)

    Edit: In response to a question asked below - what is KeychainItemWrapper?

    It's a class written by Apple that you can download here: http://developer.apple.com/library/ios/#samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_m.html

    Add it to your project and then import it where you would like to use it. Then use the code snippet I provided above.

提交回复
热议问题