• 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: When does a Prefs file get created by the NSUserDefaults defaults system?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When does a Prefs file get created by the NSUserDefaults defaults system?


  • Subject: Re: When does a Prefs file get created by the NSUserDefaults defaults system?
  • From: Jeff Disher <email@hidden>
  • Date: Fri, 29 Nov 2002 16:26:35 -0500

It sounds like your initialize method is not being called. You are creating an instance of test, right?

Put in some sort of NSLog statement or a breakpoint in that method so that you know it is being called. Then, try extracting an object for one of these keys later in the program, then try setting these objects directly with: "setObject:forKey:".

If any of those don't work, you will at least know where to start looking for problems.

Hope that helps,
Jeff.


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

Hi All,

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?

Thanks,

Rob
--
Rob Frohne, Ph.D., P.E.
E.F. Cross School of Engineering
Walla Walla College
http://www.wwc.edu/~frohro/
_______________________________________________
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.


Jeff Disher
President and Lead Developer of Spectral Class
Spectral Class: Shedding Light on Innovation
http://www.spectralclass.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.

References: 
 >When does a Prefs file get created by the NSUserDefaults defaults system? (From: Rob Frohne <email@hidden>)

  • Prev by Date: When does a Prefs file get created by the NSUserDefaults defaults system?
  • Next by Date: re: open file
  • Previous by thread: When does a Prefs file get created by the NSUserDefaults defaults system?
  • Next by thread: Re: When does a Prefs file get created by the NSUserDefaults defaults system?
  • Index(es):
    • Date
    • Thread