• 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
Retrieving "default" defaults after registerDefaults?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Retrieving "default" defaults after registerDefaults?


  • Subject: Retrieving "default" defaults after registerDefaults?
  • From: Matt Gemmell <email@hidden>
  • Date: Sun, 07 Apr 2002 21:27:19 +0100

Hi folks,

Apologies for the confusing subject-line.

When my app launches, it sets up some default values for its preferences,
and registers them using:

[[NSUserDefaults standardUserDefaults] registerDefaults:myValues];

Then I read any actual saved settings the user may previously have made.
This all works just fine, and as expected - the values in "myValues" are
used if there's no corresponding user-set value in the saved settings. I
love that behaviour; it's truly elegant, and saves me a lot of "if not nil"
nonsense when reading prefs from previous versions of my apps.

My question is, can I programmatically access the original "default" values
I registered, so that I can elegantly implement a "Factory Settings" button
in my preferences window? I want to retrieve the "default" values I
initially registered before reading the actual values the user had saved, so
that I can reset my app's settings to their factory state. I hope that makes
sense.

Note: I realise that I could just create a method which returns a dictionary
of "default" settings, and pass the output of that method to
registerDefaults, and also use that method when I want to implement the
Factory Settings button. I don't want to do that in this case since my
Preferences window uses a separate window controller, and I don't
particularly want to have outlets and connections between my app controller
and my prefs window controller just for the sake of accessing a single
method. It seems sloppy to go down that road; I'd much rather that
NSUserDefaults provided me with a way to retrieve my "default" defaults, but
I can't seem to see one. Hopefully I'm not searching in vain, and someone
can enlighten me!

By the way, I find the naming of NSUserDefaults a bit unintuitive, I must
say. To me, a "default" is a standard, fall-back, when-all-else-fails value.
It's not synonymous with a generic "setting" or "preference", as its used in
NSUserDefaults. But no matter. Thanks for reading. :)


Best,
-Matt

--
Matt Gemmell
Scotland Software
<http://www.scotlandsoftware.com/>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Retrieving "default" defaults after registerDefaults?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Several questions on Objective C
  • Next by Date: Re: Retrieving "default" defaults after registerDefaults?
  • Previous by thread: Re: Several questions on Objective C
  • Next by thread: Re: Retrieving "default" defaults after registerDefaults?
  • Index(es):
    • Date
    • Thread