---
title: "index(of:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsmenu/index(of:)"
---

# index(of:)

Returns the index identifying the location of a specified menu item in the menu.

## Declaration

```swift
func index(of item: NSMenuItem) -> Int
```

## Parameters

- `item`: A menu item—that is an object conforming to the NSMenuItem protocol.

## 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

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