Mac Developer Library

Developer

AppKit Framework Reference NSComboBoxCellDataSource Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSComboBoxCellDataSource

The NSComboBoxCellDataSource protocol declares the methods that an NSComboBoxCell uses to access the contents of its data source object.

For more information, see Combo Box Programming Topics.

Inheritance


Not Applicable

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.6 and later.
  • Returns the object that corresponds to the item at the given index in the combo box cell.

    Declaration

    Swift

    optional func comboBoxCell(_ aComboBoxCell: NSComboBoxCell, objectValueForItemAtIndex index: Int) -> AnyObject

    Objective-C

    - (id)comboBoxCell:(NSComboBoxCell *)aComboBoxCell objectValueForItemAtIndex:(NSInteger)index

    Parameters

    aComboBoxCell

    The combo box cell for which to return the item.

    index

    The index of the item to return.

    Return Value

    The object corresponding to the item at the specified index in the given combo box cell.

    Discussion

    An NSComboBoxCell object uses this method to populate the items displayed in its pop-up list.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns the number of items managed for the combo box cell by your data source object.

    Declaration

    Swift

    optional func numberOfItemsInComboBoxCell(_ aComboBoxCell: NSComboBoxCell) -> Int

    Objective-C

    - (NSInteger)numberOfItemsInComboBoxCell:(NSComboBoxCell *)aComboBoxCell

    Parameters

    aComboBoxCell

    The combo box cell for which your data source manages items.

    Return Value

    The number of items your data source object manages.

    Discussion

    An NSComboBoxCell object uses this method to determine how many items it should display in its pop-up list.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns the item from the combo box's pop-up list that matches the text entered by the user.

    Declaration

    Swift

    optional func comboBoxCell(_ aComboBoxCell: NSComboBoxCell, completedString uncompletedString: String) -> String?

    Objective-C

    - (NSString *)comboBoxCell:(NSComboBoxCell *)aComboBoxCell completedString:(NSString *)uncompletedString

    Parameters

    aComboBoxCell

    The combo box cell.

    uncompletedString

    The substring containing the text the user typed into the text field of the combo box cell.

    Return Value

    The completed string, from the items in the pop-up list, that matches the text entered by the user. Your implementation should return the first complete string that starts with uncompletedString.

    Discussion

    An NSComboBoxCell object uses this method to perform incremental—or “smart”—searches when the user types into the text field.

    As the user types in the text field, the receiver uses this method to search for items from the pop-up list that start with what the user has typed. The receiver adds the new text to the end of the field and selects the new text, so when the user types another character, it replaces the new text.

    If you don’t implement this method, the receiver does not perform incremental searches.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • 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(_ aComboBoxCell: NSComboBoxCell, indexOfItemWithStringValue aString: String) -> Int

    Objective-C

    - (NSUInteger)comboBoxCell:(NSComboBoxCell *)aComboBoxCell indexOfItemWithStringValue:(NSString *)aString

    Parameters

    aComboBoxCell

    The combo box cell.

    aString

    The string to match. If 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.