• 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: 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.


  • Follow-Ups:
    • Re: Standard User Defaults - Setting initial values
      • From: Scott Anguish <email@hidden>
References: 
 >Re: Standard User Defaults - Setting initial values (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: NSOutlineView with NSControl components
  • Next by Date: Re: Standard User Defaults - Setting initial values
  • Previous by thread: Re: Standard User Defaults - Setting initial values
  • Next by thread: Re: Standard User Defaults - Setting initial values
  • Index(es):
    • Date
    • Thread