• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Populating NSTableView from data source
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Populating NSTableView from data source (From: Matt Jaffa <email@hidden>)
 >Re: Populating NSTableView from data source (From: mmalcolm crawford <email@hidden>)
 >Re: Populating NSTableView from data source (From: Matt Jaffa <email@hidden>)

  • Prev by Date: Re: Populating NSTableView from data source
  • Next by Date: Re: Populating NSTableView from data source
  • Previous by thread: Re: Populating NSTableView from data source
  • Next by thread: Re: Populating NSTableView from data source
  • Index(es):
    • Date
    • Thread