Re: Question about TableView - how do I know which tableView?
Re: Question about TableView - how do I know which tableView?
- Subject: Re: Question about TableView - how do I know which tableView?
- From: Scott Anguish <email@hidden>
- Date: Thu, 6 Feb 2003 00:37:35 -0500
I'm writing a little app that has two table views. I thought I needed
two dataSource classes, but as Mike Beam points out in his "Working
with tables" column, the methods that are required for tableView each
expect to receive an NSTableView parameter "This argument allows for
one dataSource object to manage data for multiple table views"
So presumably I can test aTableView in some way. I think I want to
write something like
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
if [aTableView xxxxxx] isEqual: @"people"])
return [people count];
else
return [things count];
}
There are two different strategies for this.
The most common (and most flexible) is to ensure that there are
variables in the class that are set to the NSTableView object. Declare
them in the code, and then connect them up in InterfaceBuilder to the
tables.
Then you'd simply do
if (aTableView == myNamesTableView)
do something
else
the other option, is to set a tag for each of the tableviews in
Interface Builder. If you inspect the table view, you'll see a tag
field. Set that to a unique number for each table, and then you could
do
if ([aTableView tag] == 1) // its my names table
_______________________________________________
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.