Re: Standard User Defaults - Setting initial values
Re: Standard User Defaults - Setting initial values
- Subject: Re: Standard User Defaults - Setting initial values
- From: Scott Anguish <email@hidden>
- Date: Mon, 26 Apr 2004 18:47:33 -0400
On Apr 26, 2004, at 6:43 PM, Bruce Truax wrote:
You refer to an example in Listing 2 but there is no reference! Where
can I
find this listing?
Ah.. well, you can't yet. I pulled that from forthcoming doc. It
seemed easier than rewriting it
but it's simple enough to reproduce
keep your "initial" defaults in MyDefaults.plist
find the path to MyDefaults.plist in your wrapper using NSBundle
make a dictionary with dictionaryWithContentsOfFile:
register that dictionary with registerDefaults:
get the subset of that dictionary that you want to be able to "factory
reset" to (if you support this) using dictionaryWithValuesForKeys: on
the loaded dict
set those to initialValues:
Bruce
On Apr 25, 2004, at 10:27 PM, Bruce Truax wrote:
When using the Shared User Defaults Binding for UI elements, what is
the
proper way to set the initial values that the user will see on the
first
run?
Register them with NSUserDefaults using registerDefaults:. and you
need to do that before any nibs load (so an app delegate +initialize
method, or willFinishLaunching: delegate method.
---
Care must be taken that changes to the settings of the shared user
defaults controller are made before any nib files containing bindings
to the shared controller are loaded. To ensure that these changes are
made before any nib files are loaded, they are often implemented in
the
initialize class method of the application delegate, or in your
preferences window controller.
---
The initial values dictionary allows you to provide a means to reset
the user configurable default values to the factory defaults.
Typically
these values represent a subset of the defaults that your application
registers using the NSUserDefaults method registerDefaults:.
Calling the NSUserDefaultsController method setInitialValues: should
not be considered a replacement for registering your application's
preference defaults using NSUserDefault's registerDefaults: method.
The example in Listing 2 loads the default values from a file in the
application wrapper, registers those values with NSUserDefaults, and
then registers a subset of the values as the initial values of the
shared user defaults controller. The setupDefaults method would be
called from your application delegates initialize class method.
---
--
____________________________________________________________
Bruce E. Truax email: email@hidden
Optical Engineering Consultant
Diffraction Limited Design LLC
388 Wedgewood Road voice: 860-276-0450
Southington, CT 06489 fax: 860-620-9026
http://www.dld-llc.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.