NSComboBoxCellDataSource Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.6 and later.
Companion guide
Declared in
NSComboBoxCell.h

Overview

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.

Tasks

Populating Combo Boxes

Entry Completion

Instance Methods

comboBoxCell:completedString:

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

- (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.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSComboBoxCell.h

comboBoxCell:indexOfItemWithStringValue:

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

- (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.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSComboBoxCell.h

comboBoxCell:objectValueForItemAtIndex:

Returns the object that corresponds to the item at the given index in the combo box cell.

- (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.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSComboBoxCell.h

numberOfItemsInComboBoxCell:

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

- (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.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSComboBoxCell.h