Re: Help with NSDictionary!
Re: Help with NSDictionary!
- Subject: Re: Help with NSDictionary!
- From: Chris Hanson <email@hidden>
- Date: Sun, 28 Jul 2002 20:30:21 -0500
First of all, you really don't want to use this sort of mechanism for
storing your application's preferences. Instead, you want to use
NSUserDefaults. If you need finer-grained control of your
application's preferences, you want to use CFPreferences, which
operates on the same preferences database.
Secondly, this line of code:
if ([prefs objectForKey:@"FirstLaunch"]==@"YES") {
is your problem. You're comparing the pointer returned from the
expression [prefs objectForKey:@"FirstLaunch"] with the pointer to
the constant NSString @"YES". Even if the objects are equal the
pointers may not be. You want to use isEqualTo: or isEqualToString:
instead of "==". Just as in ANSI C you never want to use "==" for
string comparison.
Once your code is using NSUserDefaults like a proper Cocoa citizen,
you can just check to see if a particular key exists and if it
doesn't use that to indicate to your application is being launched
for the first time. Then just set the key in your defaults and
synchronize them.
-- Chris
--
Chris Hanson | Email: email@hidden
bDistributed.com, Inc. | Phone: +1-847-372-3955
Making Business Distributed | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
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.