<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSToolbar/insertItem(withItemIdentifier:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSToolbar(im)insertItemWithItemIdentifier:atIndex:"
  },
  "title" : "insertItem(withItemIdentifier:at:)"
}
-->

# insertItem(withItemIdentifier:at:)

Inserts an item into the toolbar at the specified index.

```
func insertItem(withItemIdentifier itemIdentifier: NSToolbarItem.Identifier, at index: Int)
```

## Parameters

`itemIdentifier`

The identifier of the toolbar item to insert.

`index`

The index at which to insert the item.

## Discussion

Typically, you don’t call this method directly from your code. Instead, you specify your toolbar’s allowed items, and the set of default items you want to appear. After that, you let the user customize the toolbar.

Any changes you make to the toolbar appear in all [`NSToolbar`](/documentation/AppKit/NSToolbar) objects with the same [`identifier`](/documentation/AppKit/NSToolbar/identifier-swift.property) value. If a toolbar item with the specified identifier isn’t available, the toolbar calls the [`toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)`](/documentation/AppKit/NSToolbarDelegate/toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)) method of its delegate to get the item. This method does not trigger a call to your delegate’s [`toolbar(_:itemIdentifier:canBeInsertedAt:)`](/documentation/AppKit/NSToolbarDelegate/toolbar(_:itemIdentifier:canBeInsertedAt:)) method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)