Skip navigation.
 
mlRe: When does a Prefs file get created by the NSUserDefaults defaults system?
FROM : Fritz Anderson
DATE : Fri Nov 29 22:53:35 2002

The code shown will not cause a preferences file to be created.

-[NSUserDefaults registerDefaults:] is there so you can provide values
for defaults in the "registration domain," which is the last-resort
place NSUserDefaults looks, if a default is not otherwise specified. In
other words, registerDefaults: specifies your _default_ preferences.

It's only when the user specifies non-default preferences, and you save
them into the application domain with -[NSUserDefaults
setObject:forKey:], that a preference file becomes necessary. It's
created then.

   -- F

On Friday, November 29, 2002, at 03:15  PM, Rob Frohne wrote:

> I'm having trouble with my application crashing when there has been a
> Preferences file created.  In trying to understand how things are
> working and how they are supposed to work, I find that the following
> code doesn't create a Preferences file, even on quitting the
> application.
>
> #import "test.h"
> @implementation test
> + (void)initialize
> {
>        //This doesn't seem to work.
>        NSUserDefaults *defaults = [NSUserDefaults
> standardUserDefaults];
>        NSMutableDictionary *appDefs = [NSMutableDictionary
> dictionary];
>
>        [appDefs setObject:@"NO" forKey:@"First Setting"];
>        [appDefs setObject:@"YES" forKey:@"Second Setting"];
>        [appDefs setObject:@"SNR" forKey:@"Third Setting"];
>
>        [defaults registerDefaults:appDefs];
> }
> @end
>
> I had thought that it was supposed to set these values as the default
> preferences, but I guess I'm wrong.  Later in the program when I write
> changes to say the "First Setting" in the defaults database, a
> Preferences file is created, and it contains that value, but not the
> others.
>
> How is this supposed to work?  Any ideas what I'm doing wrong?

  --
Fritz Anderson - Consulting Programmer - Chicago, IL
Mail:        <<email_removed>>
Risumi:    <http://resume.manoverboard.org>
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlWhen does a Prefs file get created by the NSUserDefaults defaults system? Rob Frohne Nov 29, 22:15
mlRe: When does a Prefs file get created by the NSUserDefaults defaults system? Jeff Disher Nov 29, 22:26
mlRe: When does a Prefs file get created by the NSUserDefaults defaults system? ssudre2 Nov 29, 22:43
mlRe: When does a Prefs file get created by the NSUserDefaults defaults system? Fritz Anderson Nov 29, 22:53