Re: Delegates
Re: Delegates
- Subject: Re: Delegates
- From: "I. Savant" <email@hidden>
- Date: Mon, 19 May 2008 12:58:28 -0400
> I've been trying to get my head wrapped around the concept of
> "delegates" and I thought I would run it by the list to see if I am
> approaching the correct idea behind a delegate.
Is there something about your question this document doesn't address?
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html#
As an example, using an NSTableView delegate (with or without
Bindings), -tableView:willDisplayCell:forTableColumn:row: ... you can
easily enable or disable a cell, say a checkbox. Perhaps the object
represented by that row can't have the state its checkbox represents
toggled at the moment for some reason. So, when the cell is about to
be displayed, you set it's -enabled state to NO. This method, as
explained in the documentation, is called for every cell that's
displayed. It's a handy 'hook' for such things.
Another example (again, with NSTableView) is
-selectionShouldChangeInTableView: ... you can answer "NO" if you want
to deny the user's selection change. Through 'delegation', you can
modify another object's behavior. Or you can choose not to respond to
that delegate message (by not implementing it). If it's absent, the
delegating object won't try to call it on the delegate (your object).
--
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
References: | |
| >Delegates (From: "john darnell" <email@hidden>) |