Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
- Subject: Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
- From: Mark Ritchie <email@hidden>
- Date: Mon, 17 Jan 2005 11:08:53 -0500
On Jan 17, 2005, at 10:15 AM, Guy English wrote:
So [nil intValue] will work fine and return 0 (or nil if you're
expecting and object, NO for a boolean). But "[nil floatValue]" or
"[nil frame]" will fail and you'll get an undetermined result - the
garbage that's either on the stack or sitting in the float register at
the time. I'm just pointing this out because it's an annoying bug to
track down if you're assuming that messaging nil will do the right
thing in all cases.
This has been an interesting 'feature' of Objective-C for as long
as I can remember. Apparently we need to link to a FAQ somewhere
that has a full list of all the caveats! (Although, then we'd have to
convince people to read the whole dang thing! :-)
Mark.
__
Mark Ritchie, email@hidden 416-843-5479
Software Developer, Apple Certified Developer Trainer
WebObjects, Cocoa, Mac OS X and Mac OS X Server
Diamond Lake Consulting Inc., Toronto, Ontario, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden