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?
Asked
Active
Viewed 164 times
0

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
-
1CoreData and User Defaults are two very different systems. Please separate these questions. – jscs Aug 23 '11 at 17:21
2 Answers
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!
0
Here's what I use for NSUserDefaults:
for (NSString* k in [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys])
[[NSUserDefaults standardUserDefaults] removeObjectForKey:k];

dorianj
- 101
- 3