NSMenuItem enabled state, dynamic naming and target action

cocoa, menuitem

Solution

See the NSMenuValidation protocol.

You implement -validateMenuItem:, which is used to determine whether a menu item should be enabled or disabled. It's called for each menu item just before a menu is popped up.

Problem

I am having a problem with my app's menu. I want a few items in the menu to be greyed out depending on some `BOOL` variables. Also, I want some of my menu items to get names depending on some `BOOL` variables and thereby execute different functions depending on what the menu item name is. Is this possible? As using Interface Builder you can link a menu item to one IBAction method. please tell me how to do this. Thanks

Original source