validateMenuItem:
and do something like this:
- (BOOL) validateMenuItem: (id <NSMenuItem>) menuItem { BOOL result = YES; if ([menuItem action] == @selector(deleteNote:)) { if ([notes count] == 1) { result = NO; // can't delete the last note } } else if ([menuItem action] == @selector(gotoNote:)) { if ([notes count] == 1) { result = NO; // can't go to a different not if only one } } return (result); } // validateMenuItem
NSMenuWillSendActionNotification
is posted to the notification center before the action is invoked.