• 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: Weird UserDefaults problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird UserDefaults problem


  • Subject: Re: Weird UserDefaults problem
  • From: Matt Ball <email@hidden>
  • Date: Sun, 14 Mar 2004 22:07:05 -0500

On Mar 14, 2004, at 9:58 PM, Nick Zitzmann wrote:


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.


Doh! Didn't even think about that. I've been working with Booleans all day and I'm just in that mode. Thanks!
-- Matt Ball
_______________________________________________
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: 
 >Weird UserDefaults problem (From: Matt Ball <email@hidden>)
 >Re: Weird UserDefaults problem (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Weird UserDefaults problem
  • Next by Date: Re: XML-RPC calls in Cocoa - alternative to CURLHandle?
  • Previous by thread: Re: Weird UserDefaults problem
  • Next by thread: Re: Weird UserDefaults problem
  • Index(es):
    • Date
    • Thread