• 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
Resetting screen saver preferences to default values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resetting screen saver preferences to default values


  • Subject: Resetting screen saver preferences to default values
  • From: Serge Meynard <email@hidden>
  • Date: Sat, 19 Feb 2005 16:36:23 -0500

Greetings all,

I am trying to make a "Defaults" button work in my screen saver's preferences panel. After reading the docs on ScreenSaverDefaults and NSUserDefaults, this is what I am doing to manage the prefs:

* calling userPrefs = [ScreenSaverDefaults defaultsForModuleWithName:@"myScreensaver"] to get a defaults object
* using [userPrefs registerDefaults:myDefaults] to set a dictionary containing default preference values, which end up in the NSRegistrationDomain (the last domain examined when later searching for a key)
* calling, for example, [userPrefs setInteger:someValue forKey:@"someKey"], to add or modify an entry in the application domain (which gets examined before the NSRegistrationDomain)


It seems to follow that to reset things to default values, I should simply get rid of all entries in the application domain, exposing the NSRegistrationDomain entries again... which is what removePersistentDomainForName: should do.

Unfortunately, when I run the code, it tells me that "ScreenSaverDefaults does not respond to removePersistentDomainForName:". What am I missing? ScreenSaverDefaults is a subclass of NSUserDefaults, so why wouldn't it work? The doc states that "Once you have an instance of screen saver defaults, you can use the normal methods of NSUserDefaults to load, store, or modify values." It properly responds to registerDefaults: and all the load and store methods I've used.

I suppose I can work around this by calling removeObjectForKey: on each of my preferences, especially since I only have a few; in fact this has been suggested in a few places I found in the list archives. I may even decide that it makes more sense to only restore a few of the preferences. But I'd still like to understand why a seemingly valid call isn't working. Any ideas/comments?

Serge

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Terminal view
  • Next by Date: Re: Problem with NSLineBreakByTruncatingMiddle under 10.2
  • Previous by thread: Re: Terminal view
  • Next by thread: Attachment in an NSTextView
  • Index(es):
    • Date
    • Thread