• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Revert to factory settings: how to do it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Revert to factory settings: how to do it? (From: "R. Tyler Ballance" <email@hidden>)

  • Prev by Date: Re: PDFKit: problem with PDFView goToDestination across PDFViews.
  • Next by Date: Re: Revert to factory settings: how to do it?
  • Previous by thread: Re: Revert to factory settings: how to do it?
  • Next by thread: CoreData - searching for a particular time in a date field
  • Index(es):
    • Date
    • Thread