Re: Question on cocoa style: value for (id)sender parameter
Re: Question on cocoa style: value for (id)sender parameter
- Subject: Re: Question on cocoa style: value for (id)sender parameter
- From: Matt Neuburg <email@hidden>
- Date: Mon, 24 Jan 2005 13:49:15 -0800
On Mon, 24 Jan 2005 12:24:48 -0800, Matt Gillette
<email@hidden> said:
>Hi,
>
>I have a question about the difference between these two lines (I've
>seen both styles in tutorials):
>
>[aSheet orderOut:NULL];
>[aSheet orderOut:self];
>
>Is there any advantage to null/nil versus self? What is the sender
>variable used for?
It's used for whatever you want to use it for. I've written code where the
value of the parameter, passed in code, is a signal to the method to do
something different (i.e. a way to show who is calling and why, and respond
accordingly). And of course if an interface widget sends an action, your
code might wish to know what widget it was; since it is the sender, there's
your answer. But obviously if your code has no reason to test for or speak
to the sender, then it makes no difference to you right now who the sender
is. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
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