Menu Validation

The Application Kit implements menus with the NSMenu class. After each user event, visible menu items are automatically validated. By default, a menu item is valid, and therefore enabled, if its target can respond to its action. If no object that responds to the menu item’s action is found, the menu item is invalid and disabled.

When the target for a menu item is a specific object, default validation is simple. The target either responds to the action or it does not. When the target of a menu item is nil the expanded responder chain is searched to validate the menu item. If any object in the expanded responder chain responds to the action the menu item is valid. Otherwise, it is invalid.

The default validation can be enhanced ...

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.