---
title: "comboBoxCell(_:indexOfItemWithStringValue:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscomboboxcelldatasource/comboboxcell(_:indexofitemwithstringvalue:)"
---

# comboBoxCell(_:indexOfItemWithStringValue:)

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

## Declaration

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

## Parameters

- `comboBoxCell`: The combo box cell.
- `string`: The string to match. If doc://com.apple.appkit/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

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

## Discussion

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.

## See Also

### Instance Methods

- [comboBoxCell(_:completedString:)](appkit/nscomboboxcelldatasource/comboboxcell(_:completedstring:).md)
- [comboBoxCell(_:objectValueForItemAt:)](appkit/nscomboboxcelldatasource/comboboxcell(_:objectvalueforitemat:).md)
- [numberOfItems(in:)](appkit/nscomboboxcelldatasource/numberofitems(in:).md)
