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 20:54:47 -0400
On 4/26/04 7:49 PM, "Scott Anguish" <email@hidden> eloquently wrote:
>
>
On Apr 26, 2004, at 7:46 PM, Bruce Truax wrote:
>
>
> On 4/26/04 7:09 PM, "Scott Anguish" <email@hidden> eloquently
>
> wrote:
>
>
>
>> 3. You never need to set the initialValues: unless you're going to
>
>> support resetting to the factory defaults.
>
>
>
> If I don't set the defaults then the text edit fields come up blank
>
> which
>
> can cause and error in the application if the user just hits OK. The
>
> Pop up
>
> menus and radio buttons are fine, they retain the settings from
>
> interface
>
> builder but for some reason the edit boxes do not. In my application I
>
> would
>
> like the edit boxes to contain a valid default value.
>
>
Right..
>
>
if you set the registerDefaults: and bind those text fields to the
>
appropriate key in the Shared User Defaults controller, it'll look in
>
the values set in registerDefaults: for those values.
>
>
It only falls back to the initialValues: if it can't find a value in
>
registerDefaults: and you should have on there. And since you do, you
>
shouldn't have to worry about it.
>
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.
Bruce
_______________________________________________
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.