Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Java

Table of Contents

NSTableView.DataSource


Package:
com.apple.yellow.application

Interface Description


The NSTableDataSource category declares the methods that an NSTableView uses to access the contents of its data source object. It determines how many rows to display by sending a numberOfRowsInTableView message, and accesses individual values with the tableViewObjectValueForLocation and tableViewSetObjectValueForLocation methods. A data source must implement the first two methods to work with an NSTableView, but if it doesn't implement the third the NSTableView simply provides read-only access to its contents.

The NSTableView treats objects provided by its data source as values to be displayed in NSCell objects. If these objects aren't of common value classes-such as String, Number, and so on-you'll need to create a custom NSFormatter to display them. See the NSFormatter class specification for more information.

Suppose that an NSTableView's column identifiers are set up as Strings containing the names of attributes for the column, such as "Last Name", "City", and so on, and that the data source stores its records as an NSMutableArray, called records, of NSMutableDictionary objects using those names as keys.



Method Types


Getting values
numberOfRowsInTableView
tableViewObjectValueForLocation
Setting values
tableViewSetObjectValueForLocation


Instance Methods



numberOfRowsInTableView

public abstract in numberOfRowsInTableView(NSTableView aTableView)

Returns the number of records managed for aTableView by the data source object. An NSTableView uses this method to determine how many rows it should create and display.

tableViewObjectValueForLocation

public abstract Object tableViewObjectValueForLocation( NSTableView aTableView, NSTableColumn aTableColumn, int rowIndex)

Returns an attribute value for the record in aTableView at rowIndex. aTableColumn contains the identifier for the attribute, which you get by using NSTableColumn's identifier method. For example, if aTableColumn stands for the city an employee lives in and rowIndex specifies the record for an employee who lives in Portland, this method returns an object with a string value of "Portland".

tableViewSetObjectValueForLocation

public abstract Object tableViewSetObjectValueForLocation( NSTableView aTableView, Object anObject, NSTableColumn aTableColumn, int rowIndex)

Sets an attribute value for the record in aTableView at rowIndex. anObject is the new value, and aTableColumn contains the identifier for the attribute, which you get by using NSTableColumn's identifier method.


Table of Contents