---
title: "indexOfItem(withTag:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspopupbuttoncell/indexofitem(withtag:)"
---

# indexOfItem(withTag:)

Returns the index of the menu item with the specified tag.

## Declaration

```swift
func indexOfItem(withTag tag: Int) -> Int
```

## Parameters

- `tag`: The tag of the menu item you want.

## Return Value

Return Value The index of the item or -1 if no item with the specified tag was found.

## Discussion

Discussion Tags are values your application assigns to an object to identify it. You can assign tags to menu items using the setTag: method of NSMenuItem.

## See Also

### Related Documentation

- [indexOfSelectedItem](appkit/nspopupbuttoncell/indexofselecteditem.md)

### Accessing the items

- [itemArray](appkit/nspopupbuttoncell/itemarray.md)
- [numberOfItems](appkit/nspopupbuttoncell/numberofitems.md)
- [index(of:)](appkit/nspopupbuttoncell/index(of:).md)
- [indexOfItem(withTitle:)](appkit/nspopupbuttoncell/indexofitem(withtitle:).md)
- [indexOfItem(withRepresentedObject:)](appkit/nspopupbuttoncell/indexofitem(withrepresentedobject:).md)
- [indexOfItem(withTarget:andAction:)](appkit/nspopupbuttoncell/indexofitem(withtarget:andaction:).md)
- [item(at:)](appkit/nspopupbuttoncell/item(at:).md)
- [item(withTitle:)](appkit/nspopupbuttoncell/item(withtitle:).md)
- [lastItem](appkit/nspopupbuttoncell/lastitem.md)
