Re: Revert to factory settings: how to do it?
Re: Revert to factory settings: how to do it?
- Subject: Re: Revert to factory settings: how to do it?
- From: Keary Suska <email@hidden>
- Date: Mon, 11 Dec 2006 17:11:04 -0700
- Thread-topic: Revert to factory settings: how to do it?
on 12/11/06 12:00 PM, email@hidden purportedly said:
> You can set it in a standard property list and set it from there
>
> NSString *userDefaultsValuesPath;
> NSDictionary *userDefaultsValuesDict;
>
> // load the default values for the user defaults
> userDefaultsValuesPath=[[NSBundle mainBundle]
> pathForResource:@"UserDefaults"
> ofType:@"plist"];
> userDefaultsValuesDict=[NSDictionary
> dictionaryWithContentsOfFile:userDefaultsValuesPath];
>
> // set them in the standard user defaults
> [[NSUserDefaults standardUserDefaults]
> registerDefaults:userDefaultsValuesDict];
>
> // Set the initial values in the shared user defaults controller
> [[NSUserDefaultsController sharedUserDefaultsController]
> setInitialValues:userDefaultsValuesDict];
I believe you would follow this up with:
[[NSUserDefaultsController sharedUserDefaultsController]
revertToInitialValues:self];
Alternatively, you could retrieve the total defaults database as a
dictionary using -dictionaryRepresentation and loop through the keys to
remove each one. I would personally use this approach. Seems "cleaner" to
me. Especially since I am not sure whether the above would remove keys not
referenced in the plist. It's probably a good practice, however, to do the
above and have every possible preference in the plist, especially if you
have a significant number of preferences.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden