Re: numberOfRowsInTableView
Re: numberOfRowsInTableView
- Subject: Re: numberOfRowsInTableView
- From: Bill Bumgarner <email@hidden>
- Date: Fri, 25 Apr 2003 19:30:30 -0400
On Friday, Apr 25, 2003, at 08:59 US/Eastern,
email@hidden wrote:
How do I know in my numberOfRowsInTableView which NSTableView (if I
have
more then one) was sending a message? Any example code is apreciated.
First, the delegate method is declared as follows:
// Obj-C
- (int)numberOfRowsInTableView:(NSTableView *) aTableView;
// Java
public int numberOfRowsInTableView(NSTableView aTableView);
// Python via PyObjC
class MyTableDataSource(..., NSTableDataSource):
def numberOfRowsInTableView_(self, aTableView):
In all cases, the aTableView argument is the table requesting the # of
rows for that table. Assuming you have an IBOutlet -- an instance
variable -- that is connected to the table view, you can simply compare
the references directly:
- (int)numberOfRowsInTableView:(NSTableView *) aTableView
{
if (aTableView == raceCarTableView)
return [raceCars count];
}
Or, if you are feeling pedantic, you could do it the OO way:
- (int)numberOfRowsInTableView:(NSTableView *) aTableView
{
if ([aTableView equals: raceCarTableView])
return [raceCars count];
}
In general, you'll find the answer to many such questions in the Tasks
& Concepts guide included with the developer documentation. See:
file:///Developer/Documentation/Cocoa/TasksAndConcepts/
ProgrammingTopics/
b.bum
_______________________________________________
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.