Re: Custom Delegate - Using _delegate works but not delegate or [self delegate]
Re: Custom Delegate - Using _delegate works but not delegate or [self delegate]
- Subject: Re: Custom Delegate - Using _delegate works but not delegate or [self delegate]
- From: Seth Willits <email@hidden>
- Date: Tue, 26 Mar 2013 13:52:40 -0700
On Mar 26, 2013, at 1:40 PM, Quincey Morris wrote:
>> If code expecting an NSOutlineView receives a TKOutlineView instance it may break or behave unexpectedly since it may well try to set a delegate conforming to <NSOutlineViewDelegate> but you have made your class require a delegate conforming to the more specific <TKOutlineViewDelegate>.
>
> Chris's delegate actually implements NSOutlineViewDelegate, doesn't it?
>
> Lee Ann's earlier suggestion of declaring TKOutlineViewDelegate to conform to NSOutlineViewDelegate would prevent any remaining compiler complaints. Thus the final declaration of the protocol would look like:
>
> @protocol TKOutlineViewDelegate <NSObject,NSOutlineViewDelegate>
>
> Would that take care of your concern?
No. What Conrad is really suggesting is that there's a problem if the TKOutlineViewDelegate protocol has @required methods. For example, if you hand off the TKOutlineView to AppKit (for instance) and AppKit (for some reason) changes the delegate to some other NSOutlineViewDelegate-implementing object, it won't be implementing the required TKOutlineViewDelegate methods and will lead to an issue.
One answer to the problem is to never have required methods, but in practice I would think it's plenty safe to expect a delegate to not be swapped in the vast majority of cases.
--
Seth Willits
_______________________________________________
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