insertItem(_:at:)
Inserts a menu item into the menu at a specific location.
Declaration
func insertItem(_ newItem: NSMenuItem, at index: Int)Parameters
- newItem:
An object conforming to the
NSMenuItemprotocol that represents a menu item. - index:
An integer index identifying the location of the menu item in the menu.
Discussion
This method posts an didAddItemNotification, 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 internalInconsistencyException.