Re: Populating NSTableView from data source
Re: Populating NSTableView from data source
- Subject: Re: Populating NSTableView from data source
- From: mmalcolm crawford <email@hidden>
- Date: Sat, 28 Feb 2004 14:14:50 -0800
On Feb 28, 2004, at 2:00 PM, Matt Jaffa wrote:
Yeah I saw that online documentation and it just confused me more,
A tableview gets its data from a data source, identified by its
'dataSource' instance variable (or 'dataSource' "Outlet" as its called
in Interface Builder). You can set the dataSource in IB, or
programmatically using the setDataSource: method.
The minimal responsibility of the data source object is to implement
two methods (that the table view alls automatically when necessary):
numberOfRowsInTableView: tableView:objectValueForTableColumn:row:. The
former should obviously return how many rows there are in the table
view; latter the value in a particular cell, identified by row and
column.
A test implementation:
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return 20;
}
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
return [NSCalendarDate date];
}
This will "create" a 20-row table view, where each cell's value is the
date at which it was drawn (this is instructive as it shows what rows
are actually updated as you change your selection).
For more on the data source methods, see:
<
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Protocols/NSTableDataSource.html>
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.