Table of Contents

NSComboBoxCellDataSource


Adopted by: NSObject (informal protocol)
Declared in:
AppKit/NSComboBoxCell.h



Protocol Description


The NSComboBoxCellDataSource category declares the methods that an NSComboBoxCell uses to access the contents of its data source object. The combo box cell determines how many items to display by sending a numberOfItemsInComboBoxCell: message, and accesses individual values with the comboBoxCell:objectValueForItemAtIndex: method. Incremental searches-performed when a user types into the combo box's text field while the pop-up list is displayed-are performed by sending comboBoxCell:indexOfItemWithStringValue: messages to the combo box cell's data source.

The NSComboBoxCell treats objects provided by its data source as values to be displayed in the combo box's pop-up list. If these objects aren't of common value classes-such as NSString, NSNumber, and so on-you'll need to create a custom NSFormatter to display them. See the NSFormatter class specification for more information.



Instance Methods



comboBoxCell:completedString:

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

Description forthcoming.

comboBoxCell:indexOfItemWithStringValue:

- (unsigned int)comboBoxCell:(NSComboBoxCell *)aComboBoxCell indexOfItemWithStringValue:(NSString *)aString

An NSComboBoxCell uses this method to perform incremental-or "smart"-searches when the user types into the text field with the pop-up list displayed. Your implementation of this method should return the index for the item which matches aString, or NSNotFound if no item matches. This method is optional; if you don't provide an implementation for this method, no searches occur.

comboBoxCell:objectValueForItemAtIndex:

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

Implement this method to return the object that corresponds to the item at index in aComboBoxCell. Your data source must implement this method.

numberOfItemsInComboBoxCell:

- (int)numberOfItemsInComboBoxCell:(NSComboBoxCell *)aComboBoxCell

Implement this method to return the number of items managed for aComboBoxCell by your data source object. An NSComboBoxCell uses this method to determine how many items it should display in its pop-up list. Your data source must implement this method.


Table of Contents