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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access