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: Ricky Sharp <email@hidden>
- Date: Mon, 24 Jan 2005 14:44:04 -0600
On Monday, January 24, 2005, at 02:25PM, Matt Gillette <email@hidden> wrote:
>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? I'm not just asking about orderOut, but all cocoa
>interface methods that take an (id)sender and seem to do nothing with
>it.
The term 'advantage' doesn't apply in this situation. The sender argument simply provides the receiver some contextual information.
Often times, as you've seen, the receiver never uses the value. But there are many cases that you would want to use it. For example, you could have a more general-type of action method in which several cells are connected to. The action method could then know exactly what cell send the action.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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