I have the following class hierarchy:
NSViewController
MyGeneralViewController
ViewControllerA
ViewControllerB
MyGeneralViewController
holds some common code used by both ViewControllerA
and ViewControllerB
. One piece of common code is the creation of an NSToolbar
and the implementation of the necessary protocol methods for NSToolbarDelegate
.
One of the buttons in the toolbar is a button that allows the user to open a NSTextView
into a separate window (more real estate, additional functionality for working with keywords etc).
The method for this is:
- (IBAction) openTextWindow: (id) sender {
[self setTextWindowController: [[TextWindowController alloc] init]];
[[self textWindowController] showWindow];
}
This toolbar button should only be available for the view controlled by ViewControllerA
. My reasoning was that if I implement the openTextWindow
method only for ViewControllerA
, the toolbar button would be greyed (not available) for the view controlled by ViewControllerB
, as the runtime system would go up the class hierarchy to look up the method that was defined for the toolbarbutton and not find it.
This appears to be not the case. When I implement the method with MyGeneralViewController
, the button is always available (as expected but not what I want). But when I implement it only for ViewControllerA
it's never available.
Am I missing something or is this the way it is supposed to work?