Re: Why is [nil aMessage] a no-op?
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