Re: NSUserDefault at first startup
Re: NSUserDefault at first startup
- Subject: Re: NSUserDefault at first startup
- From: "Dennis C.De Mars" <email@hidden>
- Date: Sat, 4 Oct 2003 17:06:03 -0700
The standard way of handling this according to the Cocoa documentation
on user defaults, and I find it works well, is to form a dictionary
with the keys and values for all of your user defaults. These values
are the values you want your defaults to be set to initially if they
were never set by the user. Then register this dictionary using
-registerDefaults as follows:
[NSUserDefaults registerDefaults:myFactoryDefaultsDictionary];
Then, when you do:
array = [[defaults objectForKey:@"key"] retain];
if you have the value for "key" set in your preferences plist, that
value will be returned. If not, then the value will be taken from
myFactoryDefaultsDictionary. You are getting NULL because no object is
defined for "key" until it is set.
- Dennis D.
On Saturday, October 4, 2003, at 12:18 PM, David Dauer wrote:
Hello all
I have a NSMutableArray *array; and assign this array a dictionary.
NSUserDefaults *defaults;
defaults = [NSUserDefaults standardUserDefaults];
array = [[defaults objectForKey:@"key"] retain];
But when the user start my app the first time, the array is (NULL) and
it's
not possible to set any dict or object to the array.
How to fix that?
Thanks
David
_______________________________________________
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.
_______________________________________________
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.