<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSComboBoxCellDataSource/comboBoxCell(_:indexOfItemWithStringValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSComboBoxCellDataSource(im)comboBoxCell:indexOfItemWithStringValue:"
  },
  "title" : "comboBoxCell(_:indexOfItemWithStringValue:)"
}
-->

# comboBoxCell(_:indexOfItemWithStringValue:)

Invoked by an `NSComboBoxCell` object to synchronize the pop-up list’s selected item with the text field’s contents.

```
optional func comboBoxCell(_ comboBoxCell: NSComboBoxCell, indexOfItemWithStringValue string: String) -> Int
```

## Parameters

`comboBoxCell`

The combo box cell.

`string`

The string to match. If [`comboBoxCell(_:completedString:)`](/documentation/AppKit/NSComboBoxCellDataSource/comboBoxCell(_:completedString:)) is implemented, `aString` is the string returned by that method. Otherwise, `aString` is the text that the user has typed.

## Return Value

The index for the pop-up list item matching `aString`, or `NSNotFound` if no item matches.

## Discussion

If you don’t implement this method, the receiver does not synchronize the pop-up list’s selected item with the text field’s contents.

---

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)