[Openmcl-devel] A question on how to implement delegate methods

mikel evins mevins at mac.com
Fri Feb 1 08:58:01 PST 2008


On Feb 1, 2008, at 9:05 AM, Didier Verna wrote:

>
>       Hello again,
>
> suppose that I have an outline-view somewhere, with a delegate of  
> class
> main-window-controller. It is not clear to me how I would implement  
> the
> following delegate method (objc prototype):
>
> - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem: 
> (id)item
>
>> From what I understand (correct me if I'm wrong), I would need a  
>> method
> of the form:
>
> #/outlineView: (<delegate> <the-outline-view> &key should-select-item)
>
> but what if I don't want to implement the other oulineView: delegate
> methods myself ?

Don't.

Objective-C supports enough reflection that the runtime can ask an  
object whehter it responds to a message. If a delegate doesn't  
implement a method for a message, the AppKit doesn't send that message.

In other words, it's okay to implement a delegate that responds to  
only some of the messages it can be sent.

--me





More information about the Openmcl-devel mailing list