<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSToolbarItem/init(itemIdentifier:barButtonItem:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSToolbarItem(cm)itemWithItemIdentifier:barButtonItem:"
  },
  "title" : "init(itemIdentifier:barButtonItem:)"
}
-->

# init(itemIdentifier:barButtonItem:)

Creates a toolbar item with property values from the specified bar button item.

```
convenience init(itemIdentifier: NSToolbarItem.Identifier, barButtonItem: UIBarButtonItem)
```

## Parameters

`itemIdentifier`

The identifier for the toolbar item. You use this value to identify the item within your app, so you don’t need to localize it. For example, your toolbar delegate uses this value to identify the specific toolbar item.

`barButtonItem`

The bar button item to use to create the toolbar item.

## Return Value

A new toolbar item.

## Discussion

Use this method to create and initialize a toolbar item with property values from a <doc://com.apple.documentation/documentation/UIKit/UIBarButtonItem>, such as [`title`](/documentation/AppKit/NSToolbarItem/title), [`image`](/documentation/AppKit/NSToolbarItem/image), [`action`](/documentation/AppKit/NSToolbarItem/action), and [`target`](/documentation/AppKit/NSToolbarItem/target).

> Note:
> In macOS 12 and earlier, this method doesn’t support creating a toolbar item from a bar button item that contains a custom view.

---

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)