views:

53

answers:

1

One question is : Now I want to add a new Menu at the end of MenuBar, not to add a menuitem at the known menu. just like the Xcode Items: The last menu is Help , I want to add a new Mneu(MyMenu) behind the Help Menu ? How to do ? Thanks very much!

+4  A: 

Generally, you should not add or remove items in the main menu at run time, because it breaks your users' muscle memory. Enable or disable them instead, and you'll have a much better UI.

Assuming you've found a good reason to do this, the way to do it is to get the main menu from the shared NSApplication object, then insert the menu item for your new menu. The menu item's submenu is the actual menu you're inserting. (Of course, you can create the menu and menu item in IB and access the menu item through an outlet.)

Peter Hosey