On 11/07/2008, at 12:36 PM, Dale Jensen wrote:

I have the need to modify a menu item title, so I:

a) Added a tag to the menu item in IB (selected the menu item, then went to the first "tab" of the Inspector, and added a number in the "Tag" field. I tried both 99 and 1).
b) Added this code to my function:

  NSMenu *mainMenu = [NSApp mainMenu];
  NSMenuItem *menuItemToModify = [mainMenu itemWithTag: 99];

The problem is that mainMenu is never nil, menuItemToModify always is. I tried setting the "Tag" field for some standard menu items and it still returns nil.

This seems like really super basic behaviour that should be a snap to implement, so I'm guessing that I'm missing something really obvious.

The problem almost certainly is that the main menu is a menu of menus e.g. File, View, Format, Window, Help, etc. and you're trying to access one of the menu items of those menus.

In any case, I think you're taking the wrong approach. It's better to declare an outlet somewhere and connect your menu item to it within Interface Builder then you don't need to go searching for it.

--Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to