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

# indexOfItem(withRepresentedObject:)

Returns the index of the first menu item in the menu that has a given represented object.

## Declaration

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

## Parameters

- `object`: A represented object 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)

### Finding Indices of Menu Items

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