• 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: Scott Anguish <email@hidden>
  • Date: Mon, 26 Apr 2004 19:09:05 -0400

OK, there are a number of issues here..

1. awake from nib is too late. You need to do it before any nibs are loaded. either +initialize, or appWillFinishLaunching:
2. There is no setInitialValues: on NSUserDefaults, it's on NSUserDefaultsController

[[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:]

3. You never need to set the initialValues: unless you're going to support resetting to the factory defaults.







On Apr 26, 2004, at 6:43 PM, Bruce Truax wrote:

Mmalcom,

Here is my code for setting and registering the defaults and my attempt in
my awakeFromNib method to set the initial values. This does not appear to
work. I tried moving the setInitialValues call into the initialize function
but that does not work either.

+ (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];


}

- (void)awakeFromNib
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefs = [defs dictionaryRepresentation];
[standardDefaultsController setInitialValues:appDefs];

[window setFrameUsingName:@"Nodal Properties Dialog"];
[window setFrameAutosaveName:@"Nodal Properties Dialog"];
}

Bruce


On 4/26/04 1:41 AM, "mmalcolm crawford" <email@hidden> eloquently
wrote:


On Apr 25, 2004, at 7: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?

- (void)setInitialValues:(NSDictionary *)initialValues

Note that this does not register defaults with NSUserDefaults'
standardUserDefaults -- you must do this as well.

mmalc


--
____________________________________________________________
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.
_______________________________________________
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: Standard User Defaults - Setting initial values
      • From: Bruce Truax <email@hidden>
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: Re: Table data not initializing [Solved]
  • Previous by thread: Re: Standard User Defaults - Setting initial values
  • Next by thread: Re: Standard User Defaults - Setting initial values
  • Index(es):
    • Date
    • Thread