Right, I'm officially confused.
This is called in a NSTableView
subclass on 10.8 and as we can learn from the docs and the headers NSTableView
implements NSDraggingSource
so all should be good:
if ([super respondsToSelector:@selector(draggingSession:movedToPoint:)])
[super draggingSession:session movedToPoint:screenPoint];
When the containing method (override of draggingSession:movedToPoint:
in the subclass) is called, the second line however throws the beloved 'unrecognized selector sent to instance 0x1054092c0' exception.
Could anybody please explain what is going on here?!
First, [super respondsToSelector:@selector(draggingSession:movedToPoint:)]
is the same as [self respondsToSelector:@selector(draggingSession:movedToPoint:)]
. super
allows you to invoke the superclass implementation of the given method; in this case, respondsToSelector:
. But if your class (or whatever class this object is) does not override -respondsToSelector:
(99.9% of classes will not need to override -respondsToSelector:
), then the superclass implementation is the same as the implementation of the class of self
. Basically, in both cases, you are checking to see if the current object (self
) responds to the selector.
So, what you're seeing is this: self
responds to the selector, but the superclass of the class this is in does not have an implementation for the selector. What does that mean? Either the current class, or somewhere between the current class as the class of self
, this method is implemented. That's why self
responds to it. But there is no superclass implementation.