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

# indexOfItem(withRepresentedObject:)

Returns the index of the menu item that holds the specified represented object.

## Declaration

```swift
func indexOfItem(withRepresentedObject obj: Any?) -> Int
```

## Parameters

- `obj`: The represented object associated with a menu item.

## Return Value

Return Value The index of the menu item that owns the specified object, or -1 if no such menu item was found.

## 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(withTag:)](appkit/nspopupbuttoncell/indexofitem(withtag:).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)
