Instance Method


Inserts a menu item into the menu at a specific location.


- (void)insertItem:(NSMenuItem *)newItem atIndex:(NSInteger)index;



An object conforming to the NSMenuItem protocol that represents a menu item.


An integer index identifying the location of the menu item in the menu.


This method posts an NSMenuDidAddItemNotification, allowing interested observers to update as appropriate. This method is a primitive method. All item-addition methods end up calling this method, so this is where you should implement custom behavior on adding new items to a menu in a custom subclass. If the menu item already exists in another menu, it is not inserted and the method raises an exception of type NSInternalInconsistencyException.

See Also

Adding and Removing Menu Items

- insertItemWithTitle:action:keyEquivalent:atIndex:

Creates and adds a menu item at a specified location in the menu.

- addItem:

Adds a menu item to the end of the menu.

- addItemWithTitle:action:keyEquivalent:

Creates a new menu item and adds it to the end of the menu.

- removeItem:

Removes a menu item from the menu.

- removeItemAtIndex:

Removes the menu item at a specified location in the menu.

- itemChanged:

Invoked when a menu item is modified visually (for example, its title changes).

- removeAllItems

Removes all the menu items in the menu.