Re: Weird UserDefaults problem
Re: Weird UserDefaults problem
- Subject: Re: Weird UserDefaults problem
- From: Nick Zitzmann <email@hidden>
- Date: Sun, 14 Mar 2004 19:58:28 -0700
On Mar 14, 2004, at 7:45 PM, Matt Ball wrote:
homePage = [[NSUserDefaults standardUserDefaults]
objectForKey:@"HomePageAddress"];
if(homePage == nil)
{
homePage = @"http://www.apple.com";
}
First of all, you ought to retain these values or else they might be
deallocated later, which would cause a crash if your application tried
to access them...
if(openNewWindowWithPageType == @"Empty Page")
{
}
Second, this type of comparison doesn't work, because it's comparing
the memory addresses but not the content. Just like you'd need to use
strncmp() to compare two C strings, you must use an NSString method to
check the equality of two strings:
if ([openNewWindowWithPageType isEqualToString:@"Empty Page"])
{
}
...and so on. See the NSString documentation for details.
Nick Zitzmann
<
http://seiryu.home.comcast.net/>
<
http://www.freshlysqueezedsoftware.com/>
S/MIME signature available upon request
UNIX: Where /sbin/init is Job #1.
_______________________________________________
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.