• 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: Why is [nil aMessage] a no-op?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is [nil aMessage] a no-op?


  • Subject: Re: Why is [nil aMessage] a no-op?
  • From: "Sherm Pendley" <email@hidden>
  • Date: Fri, 18 Apr 2008 01:52:15 -0400

On Fri, Apr 18, 2008 at 12:56 AM, Adam P Jenkins <email@hidden>
wrote:

>
> Can you give an example of where invoking methods on nil objects would
> make sense in a non-error-path situation?   I'm not trying to be
> argumentative here, I'm really curious to know what Objective-C idioms take
> advantage of the nil-swallows-messages behavior.  Thank you.


Delegate messages come to mind. If you're writing a class that may have a
delegate, you can send messages like [delegate didThis] without having to be
concerned about whether a delegate has actually been assigned or not.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Why is [nil aMessage] a no-op? (From: Adam P Jenkins <email@hidden>)
 >Re: Why is [nil aMessage] a no-op? (From: Bill Bumgarner <email@hidden>)
 >Re: Why is [nil aMessage] a no-op? (From: Adam P Jenkins <email@hidden>)
 >Re: Why is [nil aMessage] a no-op? (From: Bill Bumgarner <email@hidden>)
 >Re: Why is [nil aMessage] a no-op? (From: Adam P Jenkins <email@hidden>)

  • Prev by Date: Re: Why is [nil aMessage] a no-op?
  • Next by Date: Re: Why is [nil aMessage] a no-op?
  • Previous by thread: Re: Why is [nil aMessage] a no-op?
  • Next by thread: Re: Why is [nil aMessage] a no-op?
  • Index(es):
    • Date
    • Thread