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

# indexOfItem(withSubmenu:)

Returns the index of the menu item in the menu with the given submenu.

## Declaration

```swift
func indexOfItem(withSubmenu submenu: NSMenu?) -> Int
```

## Parameters

- `submenu`: A menu object that is a menu item of the menu (that is, a submenu).

## 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(withRepresentedObject:)](appkit/nsmenu/indexofitem(withrepresentedobject:).md)
