Re: Delegates
Re: Delegates
- Subject: Re: Delegates
- From: "I. Savant" <email@hidden>
- Date: Mon, 19 May 2008 16:23:29 -0400
On Mon, May 19, 2008 at 2:54 PM, Michael Vannorsdel <email@hidden> wrote:
> There's nothing that guarantees a Cocoa delegate will act for another object
> and that the represented object won't act how it wants as well. Sometimes a
> delegate method is just a notification something happened/happening without
> the delegate having any say on the matter or affect on the represented
> object's course of action on that matter.
Yes, but the delegating object *always* follows this pattern:
- I'm doing something for which I can ask a delegate for assistance or
advice or in which the delegate might be interested, so ...
- If I have a delegate ...
- If the delegate responds to this particular delegate message
- Send the message to the delegate and *wait for it to return* (ie,
it's all within the same trip around the run loop, unlike
notifications).
No, the delegate may not:
1 - Respond to the selector (message/method).
2 - Do anything about a "just letting you know" kind of message.
3 - Return anything but the default answer when asked a "just
wondering if I should/can".
4 - Function correctly.
In the case of 1, no harm (as in notifications). In the case of 2-4,
the delegating object *will* wait for the delegate to complete and
return execution to. VERY UNLIKE notifications. It behaves very
differently.
> I'm just saying Cocoa delegates don't always act in dictionary form.
> I know this discussion can go round and round, but I still think reading the
> english dictionary for delegates won't tell you the whole story on Cocoa
> delegates.
Oh come on ... semantics. The term "delegate" is exactly appropriate
for this behavior. Nothing else is more appropriate and nothing about
the 'delegate' behavior of Cocoa contradicts or lay outside the
English definition for the verb 'to delegate' except that the
dictionary refers to 'people' instead of 'objects'.
I think that's the last I'll comment on the dictionary definition
matter; it's a silly argument. Suffice to say I was more concerned
with precision and it's vitally important to realize that delegation
has more dissimilarities than similarities with notifications.
--
I.S.
_______________________________________________
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