I am trying to send an action from a menu item to a child view controller of a NSSplitViewController. As I understand I am supposed to override supplementalTargetForAction:sender:
on the splitViewController to provide the child view controller to the responder chain (see this post).
However, supplementalTargetForAction:sender:
never gets called.
The documentation states:
If this NSResponder instance does not itself respondsToSelector:, then supplementalTargetForAction:sender: is called.
In a debugging effort I have created a fresh Xcode project with just a normal viewController, overridden the method there to see if it gets called - it doesn't.
Here's my code:
@implementation ViewController
- (BOOL)respondsToSelector:(SEL)aSelector {
NSString *s = NSStringFromSelector(aSelector);
if ([s hasPrefix:@"foo"]) {
// let's pretend we do not respond here.
// I expect `supplementalTargetForAction:sender:` to get called.
return NO;
}
return [super respondsToSelector:aSelector];
}
- (id)supplementalTargetForAction:(SEL)action sender:(id)sender {
// nobody calls me ever :(
return [super supplementalTargetForAction:action sender:sender];
}
- (IBAction)foo:(id)sender {
NSLog(@"Foo");
}
@end
What am I doing wrong?