item(forIdentifier:)
Returns the Touch Bar item that corresponds to a given identifier.
Declaration
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 class) as it finds them, according to the following search order, listed here from first-searched to last-searched:
Items in the bar’s private array, which are reflected in the value of the itemIdentifiers array.
Items in the templateItems array.
Items returned from the bar delegate’s 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 |
|---|---|
small space | |
large space | |
flexible space | |
proxy placeholder |
For more on the proxy placeholder, see Composition and nesting.