0

I want to create a button in my application that will delete all entries in core data as well as all of the NSUserDefaults. What method would I use to do this?

Baub
  • 5,004
  • 14
  • 56
  • 99
  • possible duplicate of [NSUserDefaults reset](http://stackoverflow.com/questions/6358737/nsuserdefaults-reset) – jscs Aug 23 '11 at 17:21
  • 1
    CoreData and User Defaults are two very different systems. Please separate these questions. – jscs Aug 23 '11 at 17:21

2 Answers2

2

This method:

[[NSUserDefaults standardUserDefaults] setPersistentDomain:[NSDictionary dictionary] forName:[[NSBundle mainBundle] bundleIdentifier]];

resets the defaults to the registration domain, which means that removeObjectForKey is called to all the keys. I found it from this link. Hope that helps!

Community
  • 1
  • 1
msgambel
  • 7,320
  • 4
  • 46
  • 62
0

Here's what I use for NSUserDefaults:

for (NSString* k in [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys])
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:k];
dorianj
  • 101
  • 3