<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTabViewController/toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTabViewController(im)toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:"
  },
  "title" : "toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)"
}
-->

# toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)

Returns the toolbar item for the specified identifier.

```
@MainActor func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem?
```

## Parameters

`toolbar`

The toolbar making the request.

`itemIdentifier`

The identifier of the toolbar item being requested.

`flag`

A Boolean indicating whether the item is inserted immediately into the toolbar. A value of <doc://com.apple.documentation/documentation/Swift/true> means the item is inserted into the toolbar. A value of <doc://com.apple.documentation/documentation/Swift/false> means the item is added to the toolbar’s configuration palette. The same item may be requested more than once with different values for this flag.

## Return Value

The requested toolbar item or `nil` to indicate that the specified item is not supported. When the same item is requested again, you may return the same [`NSToolbarItem`](/documentation/AppKit/NSToolbarItem) object or a different one.

## Discussion

This method is called for tab view interfaces that use the [`NSTabViewController.TabStyle.toolbar`](/documentation/AppKit/NSTabViewController/TabStyle-swift.enum/toolbar) style. Use this method to create toolbar items for any custom identifiers you specified in the [`toolbarAllowedItemIdentifiers(_:)`](/documentation/AppKit/NSTabViewController/toolbarAllowedItemIdentifiers(_:)) and [`toolbarDefaultItemIdentifiers(_:)`](/documentation/AppKit/NSTabViewController/toolbarDefaultItemIdentifiers(_:)) methods.

If you override this method, you must call `super` at some point in your implementation. The default implementation of this method returns toolbar items for the tabs in the tab bar interface. The identifier for each toolbar item is the same as the identifier for the corresponding tab view item. Similarly, the toolbar item’s [`label`](/documentation/AppKit/NSToolbarItem/label), [`image`](/documentation/AppKit/NSToolbarItem/image) and [`toolTip`](/documentation/AppKit/NSToolbarItem/toolTip) properties are bound to those of the corresponding tab view item.

---

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)