Search code examples
iphoneobjective-carchivenskeyedarchiver

Remove data from NSKeyedArchvier


I am storing data with NSKeyedArchiver. When a user logs out of my app, I would like to clear all the data that I have stored. How can I go about doing that? It doesn't appear that [NSKeyedUnarchiver unarchiveObjectWithFile:] removes the file.

Thanks!


Solution

  • NSKeyedArchiver & NSKeyedUnarchiver only encode and decode your objects so they can be stored and retreived. If you are storing the data in a file, just delete the file (use NSFileManager). If you are storing data in other places (eg NSUserDefaults, a database, etc) then you need to delete the data as appropriate for the store.