---
title: "indexOfItem(withTag:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspopupbutton/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 This method invokes the method of the same name of its NSPopUpButtonCell object.

## See Also

### Getting the indices of menu items

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