Next Page > Hide TOC

NSComboBoxCellDataSource Protocol Reference

(informal protocol)

Framework
/System/Library/Frameworks/AppKit.framework
Companion guide
Declared in
NSComboBoxCell.h

Overview

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

For more information, see “Providing Data for a Combo Box”.

Tasks

Returning Information About Combo Box Items

Working with Entered Strings

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.

This method is optional. If you don’t implement it, the receiver does not perform incremental searches.

Availability
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

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

Availability
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

Your data source must implement this method.

Availability
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. Your data source must implement this method.

Availability
Declared In
NSComboBoxCell.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.