Re: how to test for NULL (or nil, or null)
Re: how to test for NULL (or nil, or null)
- Subject: Re: how to test for NULL (or nil, or null)
- From: Pete Yandell <email@hidden>
- Date: Mon, 1 Mar 2004 09:47:01 +1100
On 01/03/2004, at 9:38 AM, Denis Stanton wrote:
Now that I look at it again, using == to compare two objects seems
wrong. Shouldn't it be isEqual: ? Or is that what the words "unique
object" are saying - [NSNull null] is a spacial case that == any other
NULL ?
Yep, you're spot on. The system maintains a single global NSNull
object, so a pointer comparison to [NSNull null] works. For just about
everything else, isEqual: is the way to compare the contents of
objects.
In fact, now that I think about it, you probably can do:
if ([myObject isEqual:[NSNull null]])
I'll leave it to you to decide which is better coding style. :)
Pete Yandell
http://pete.yandell.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.