Menu Validation
Enabling and disabling menu items is done automatically by Cocoa. A menu item will be disabled automatically if it has no action assigned or its target doesn’t respond to its action. In the case of a nil target, the responder chain is queried to see if there is an object that can respond to the action. If not, the menu item will be disabled. In many cases, this is all that needs to be done, and there is nothing required of developers to make it happen. Menu items will be enabled and disabled automatically as selections change.
For menu items that do not send actions to the first responder, however, further validation might be required. Sending a particular message to an object might not make sense when the object is in a certain ...
Get Cocoa® Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.