<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.2 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTouchBar/item(forIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTouchBar(im)itemForIdentifier:"
  },
  "title" : "item(forIdentifier:)"
}
-->

# item(forIdentifier:)

Returns the Touch Bar item that corresponds to a given identifier.

```
func item(forIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem?
```

## Return Value

A Touch Bar item if one exists for the given identifier; otherwise, returns `nil`.

## Discussion

The system returns items (instances of the [`NSTouchBarItem`](/documentation/AppKit/NSTouchBarItem) class) as it finds them, according to the following search order, listed here from first-searched to last-searched:

1. Items in the bar’s private array, which are reflected in the value of the [`itemIdentifiers`](/documentation/AppKit/NSTouchBar/itemIdentifiers) array.
2. Items in the [`templateItems`](/documentation/AppKit/NSTouchBar/templateItems) array.
3. Items returned from the bar delegate’s [`touchBar(_:makeItemForIdentifier:)`](/documentation/AppKit/NSTouchBarDelegate/touchBar(_:makeItemForIdentifier:)) method.

Your app never needs to instantiate spacing or proxy items because these are created by the system directly, according to their identifiers, as shown in the table below.

|Constant                                                                                              |Resulting item   |
|------------------------------------------------------------------------------------------------------|-----------------|
|``doc://com.apple.appkit/documentation/AppKit/NSTouchBarItem/Identifier-swift.struct/fixedSpaceSmall``|small space      |
|``doc://com.apple.appkit/documentation/AppKit/NSTouchBarItem/Identifier-swift.struct/fixedSpaceLarge``|large space      |
|``doc://com.apple.appkit/documentation/AppKit/NSTouchBarItem/Identifier-swift.struct/flexibleSpace``  |flexible space   |
|``doc://com.apple.appkit/documentation/AppKit/NSTouchBarItem/Identifier-swift.struct/otherItemsProxy``|proxy placeholder|

For more on the proxy placeholder, see [`Composition and nesting`](/documentation/AppKit/NSTouchBar#Composition-and-nesting).

---

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)