<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPopUpButtonCell/indexOfItem(withTag:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPopUpButtonCell(im)indexOfItemWithTag:"
  },
  "title" : "indexOfItem(withTag:)"
}
-->

# indexOfItem(withTag:)

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

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

## Parameters

`tag`

The tag of the menu item you want.

## Return Value

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

## 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`](/documentation/AppKit/NSMenuItem).

## See Also

[`indexOfSelectedItem`](/documentation/AppKit/NSPopUpButtonCell/indexOfSelectedItem)

The index of the item last selected by the user.



---

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)