• 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: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Guy English <email@hidden>
  • Date: Mon, 17 Jan 2005 10:15:29 -0500

On Mon, 17 Jan 2005 08:22:08 -0500, Mark Ritchie <email@hidden>
> On Jan 17, 2005, at 2:16 AM, Robin Hermann wrote:
> > Can't find very much info (Apple Docs, Google) on NULL, Nil and nil
> > though.
> The handy thing about nil is that you can legally send messages to nil
> in Objective-C.
> [nil someMethodName] is quite legal and in fact, relied upon regularly.

While this is true there are a couple of gotchas to it. Sending a
message to nil will return you a 0 in the standard function return
register. This sounds nice until you call a  method that returns a
float (returned in a float register) or a structure (on the stack).

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.

Guy
 _______________________________________________
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

  • Follow-Ups:
    • Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
      • From: Mark Ritchie <email@hidden>
References: 
 >NSData testing for NULL (From: Robin Hermann <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Robin Hermann <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Mark Ritchie <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Robin Hermann <email@hidden>)
 >Definition of Nil and nil was: NSData testing for NULL [SOLVED] (From: Mark Ritchie <email@hidden>)

  • Prev by Date: Re: Having NSSecureTextField display the hidden text
  • Next by Date: Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
  • Previous by thread: Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
  • Next by thread: Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
  • Index(es):
    • Date
    • Thread