Search code examples
iphoneobjective-cnsdictionarykeychainsfhfkeychainutils

How can I delete all values from SFHFKeychainUtils?


For deleting a value from keychain following code is available:

[SFHFKeychainUtils deleteItemForUsername:XYZ andServiceName:@"known" error:&err]

Is there any way to remove all stored values in keychain using only service name ?

My problem is that my key value is dynamic in nature. It's truly possible that I don't know XYZ value when I will run App second time. There is a case where I have to remove all values stored in known service.

How can i remove all value if I don't know XYZ ?


Solution

  • In my honest opinion there is no api call provided by SFHFKeychainUtils by which you can delete all entries at once and as you might be knowing that iOS keychain only allows you to delete those entries which belong to your applications (sandbox rule coming in play here) , so if you wish to delete all entries for your application then I would suggest you keep track of all the usernames in a file in documents directory or NSUserDefaults so that you can delete them one by one.. hope this helps.