Contents

comboBox(_:indexOfItemWithStringValue:)

Returns the index of the combo box item matching the specified string.

Declaration

@MainActor optional func comboBox(_ comboBox: NSComboBox, indexOfItemWithStringValue string: String) -> Int

Parameters

  • comboBox:

    The combo box.

  • string:

    The string to match against the items in the combo box. If the datasource implementsCombobox(_:completedstring:), this is the string returned by that method. Otherwise, it is the text that the user has typed.

Return Value

The index for the item that matches the specified string, or NSNotFound if no item matches.

Discussion

An NSComboBox object uses this method to synchronize the pop-up list’s selected item with the text field’s contents. 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