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

# indexOfItem(withTag:)

Returns the index of the first menu item in the menu identified by a tag.

## Declaration

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

## Parameters

- `tag`: An integer tag associated with the menu item of the menu.

## Return Value

Return Value The integer index of the menu item or, if no such menu item is in the menu, –1.

## See Also

### Related Documentation

- [item(at:)](appkit/nsmenu/item(at:).md)
- [insertItem(_:at:)](appkit/nsmenu/insertitem(_:at:).md)
- [item(withTag:)](appkit/nsmenu/item(withtag:).md)

### Finding Indices of Menu Items

- [index(of:)](appkit/nsmenu/index(of:).md)
- [indexOfItem(withTitle:)](appkit/nsmenu/indexofitem(withtitle:).md)
- [indexOfItem(withTarget:andAction:)](appkit/nsmenu/indexofitem(withtarget:andaction:).md)
- [indexOfItem(withRepresentedObject:)](appkit/nsmenu/indexofitem(withrepresentedobject:).md)
- [indexOfItem(withSubmenu:)](appkit/nsmenu/indexofitem(withsubmenu:).md)
