• 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: Standard User Defaults - Setting initial values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Standard User Defaults - Setting initial values


  • Subject: Re: Standard User Defaults - Setting initial values
  • From: Chris Parker <email@hidden>
  • Date: Mon, 26 Apr 2004 18:30:24 -0700

On Apr 26, 2004, at 5:54 PM, Bruce Truax wrote:

That is what I thought I was doing in the initialize function but for some
reason that is not what is happening. Am I making a mistake in the binding?
As an example, I am binding the value parameter to Shared User Defaults with
the Controller Key set to values and the Model Key path set to
FO_StartingSurface. Just a a refresher, here is how I register my defaults
for this case:

+ (void)initialize
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *appDefs = [NSMutableDictionary dictionary];
[appDefs setObject:@"0" forKey:@"FO_Plane"];
[appDefs setObject:@"1" forKey:@"FO_Wavelength"];
[appDefs setObject:@"1" forKey:@"FO_StartingSurface"];
[appDefs setObject:@"-1" forKey:@"FO_EndingSurface"];

[defaults registerDefaults:appDefs];
}

I thought that the statements in the initialize function would automatically
cause these keys to show up in the .plist preferences file, but nothing
appears in that file until I actually type something into the edit boxes or
change the radio boxes in the dialog.

Defaults registered in this way appear in the "Registration Domain" which is not written out to disk - they'll be picked up by NSUserDefaults, but they're not serialized into a plist. The registration domain is a volatile domain, held only in memory. More information on this is available at

http://developer.apple.com/documentation/Cocoa/Conceptual/UserDefaults/ Concepts/DefaultsDomains.html

If you were to programmatically retrieve any of the values for these keys, you'd find they'd be there - unless the user had set a value for them, of course. :)

.chris

--
Chris Parker
Cocoa Frameworks Engineer
Apple Computer, Inc.
_______________________________________________
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.


References: 
 >Re: Standard User Defaults - Setting initial values (From: Bruce Truax <email@hidden>)

  • Prev by Date: Getting hold of a Documents Window for displaying a Sheet
  • Next by Date: SOLVED Standard User Defaults - Setting initial values
  • Previous by thread: Re: Standard User Defaults - Setting initial values
  • Next by thread: SOLVED Standard User Defaults - Setting initial values
  • Index(es):
    • Date
    • Thread