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

# indexOfItem(withRepresentedObject:)

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

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

## Parameters

`obj`

The represented object associated with a menu item.

## Return Value

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

## Discussion

Represented objects bear some direct relation to the title or image of a menu item; for example, an item entitled “100” might have an `NSNumber` object encapsulating that value as its represented object. This method invokes the method of the same name of its `NSPopUpButtonCell` object.

---

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)