-draggingEnded
Christiaan Hofman
cmhofman at gmail.com
Wed Nov 14 08:10:04 PST 2007
On 14 Nov 2007, at 4:52 PM, David Dunham wrote:
>
> On 14 Nov 2007, at 01:44, Christiaan Hofman wrote:
>
>> NSDraggingSource is an informal protocol, which means it may be
>> implemented in some views (like NSTableView) and in other cases
>> you may have to implement it yourself. I don't know what
>> CellEditor is, but it sure does not sound like a subclass of a
>> view that implements it.
>
>
> CellEditor is my class, and I do implement draggingEnded:. The
> exception comes when I call super (an NSTextView).
>
> It's even worse -- I changed the code to
>
> - (void) draggingEnded: (id <NSDraggingInfo>) aSender
> // ...
> if ([super respondsToSelector: @selector(draggingEnded:)])
> [super draggingEnded: aSender];
>
> and still get unrecognized selector.
>
That code is totally wrong. It does not check whether the superclass
implements draggingEnded:, it just uses the superclass's
implementation of -respondsToSelector: to check whether the object
itself implements it ('super' does not change the receiver, only the
method implementation). As this is the same as self's implementation,
your code is equivalent to:
- (void) draggingEnded: (id <NSDraggingInfo>) aSender
// ...
if ([self respondsToSelector: @selector(draggingEnded:)])
[super draggingEnded: aSender];
and as you're guaranteed to implement to draggingEnded: it is
equivalent to:
- (void) draggingEnded: (id <NSDraggingInfo>) aSender
// ...
if (YES)
[super draggingEnded: aSender];
So it's no wonder it will fail. You should do this:
if ([[CellEditor superclass] instancesRespondToSelector:_cmd])
[super draggingEnded: aSender];
As a general remark on your question, note that the release notes do
not say *where* draggingEnded: is implemented, only that it is
implemented *somewhere*. Certainly, it is not implemented everywhere
(i.e. in NSObject). Maybe it is only *called* at the correct time
now? I agree they should have indicated what they mean with this
sentence, because it basically contains no information.
Christiaan
> David Dunham
> Voice/Fax: 206 783 7404 http://www.pensee.com/dunham/
> Imagination is more important than knowledge. -- Albert Einstein
>
>
> David Dunham A Sharp, LLC
> Voice/Fax: 206 783 7404 http://a-sharp.com
> Efficiency is intelligent laziness.
>
> _______________________________________________
> MacOSX-dev mailing list
> MacOSX-dev at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
More information about the MacOSX-dev
mailing list