I'm using +[NSUserDefaults standardUserDefaults]
to store application settings. This consists of roughly a dozen string values. Is it possible to delete these values permanently instead of just setting them to a default value?
views:
1839answers:
2
+5
A:
Did you try using -removeObjectForKey?
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"defunctPreference"];
sbooth
2009-02-13 07:51:56
Cheers sbooth. Much Appreciated.
TonyNeallon
2009-02-13 10:16:06
Any way to remove object for all existing keys?
Sam V
2010-06-10 03:30:21
+5
A:
This code resets the defaults to the registration domain:
[[NSUserDefaults standardUserDefaults] setPersistentDomain:[NSDictionary dictionary] forName:[[NSBundle mainBundle] bundleIdentifier]];
In other words, it removeObjectForKey
for every single key you ever registered in that app.
Credits to Ken Thomases on this Apple Developer Forums thread.
Sam V
2010-06-10 04:40:08