Re: Standard User Defaults - Setting initial values
Re: Standard User Defaults - Setting initial values
- Subject: Re: Standard User Defaults - Setting initial values
- From: Bruce Truax <email@hidden>
- Date: Mon, 26 Apr 2004 18:43:15 -0400
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.