<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSToolbarDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSToolbarDelegate"
  },
  "title" : "NSToolbarDelegate"
}
-->

# NSToolbarDelegate

A set of optional methods you use to configure the toolbar and respond to changes.

```
protocol NSToolbarDelegate : NSObjectProtocol
```

## Overview

Use the methods of [`NSToolbarDelegate`](/documentation/AppKit/NSToolbarDelegate) to customize the behavior of your toolbars. You might use these methods to track the addition or removal of toolbar items, or use them to prevent someone from rearranging or removing specific items. Adopt this protocol in one of your custom objects and assign that object to the [`delegate`](/documentation/AppKit/NSToolbar/delegate) property of the [`NSToolbar`](/documentation/AppKit/NSToolbar) object you want to manage.

## Topics

### Adding and removing items

[`-  toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:`](/documentation/AppKit/NSToolbarDelegate/toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:))

Asks the delegate for the toolbar item associated with the specified identifier.

[`-  toolbarWillAddItem:`](/documentation/AppKit/NSToolbarDelegate/toolbarWillAddItem(_:))

Tells the delegate that the toolbar is about to add the specified item.

[`-  toolbarDidRemoveItem:`](/documentation/AppKit/NSToolbarDelegate/toolbarDidRemoveItem(_:))

Tells the delegate that the toolbar removed the specified item.

[`Identifier`](/documentation/AppKit/NSToolbar/Identifier-swift.typealias)

A string value that you use to differentiate your app’s toolbars.

### Configuring the behavior of items

[`-  toolbarAllowedItemIdentifiers:`](/documentation/AppKit/NSToolbarDelegate/toolbarAllowedItemIdentifiers(_:))

Asks the delegate to provide the items allowed on the toolbar.

[`-  toolbarDefaultItemIdentifiers:`](/documentation/AppKit/NSToolbarDelegate/toolbarDefaultItemIdentifiers(_:))

Asks the delegate to provide the default items to display on the toolbar.

[`-  toolbarImmovableItemIdentifiers:`](/documentation/AppKit/NSToolbarDelegate/toolbarImmovableItemIdentifiers(_:))

Asks the delegate to provide the items that people can’t remove from the toolbar or rearrange during the customization process.

[`-  toolbarSelectableItemIdentifiers:`](/documentation/AppKit/NSToolbarDelegate/toolbarSelectableItemIdentifiers(_:))

Asks the delegate to provide the set of selectable items in the toolbar.

[`-  toolbar:itemIdentifier:canBeInsertedAtIndex:`](/documentation/AppKit/NSToolbarDelegate/toolbar(_:itemIdentifier:canBeInsertedAt:))

Asks the delegate for a Boolean value that indicates whether the toolbar can place the item at the specified position.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Conforming Types

[`NSTabViewController`](/documentation/AppKit/NSTabViewController)

---

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)