Re: Multiple NSTableView question
Re: Multiple NSTableView question
- Subject: Re: Multiple NSTableView question
- From: Joe Schiwall <email@hidden>
- Date: Wed, 20 Jun 2001 22:31:39 -0400
on 6/20/01 6:53 PM, Jason Brown at email@hidden wrote:
>
I keep reading that by evaluating the theTableView argument used in
>
>
- (int)numberOfRowsInTableView:(NSTable *)theTableView
>
>
and
>
>
- (id)tableView:(NSTableView *)theTableView
>
objectValueForTableColumn:(NSTableColumn *)theColumn
>
row:(int)rowIndex
>
>
>
you can distinguish which table view is invoking these methods, when
>
using more than one table view.
>
>
My question is this: Evaluate it against what? What can I do with
>
that argument to figure out which table view is making the given
>
calls?
If you have a controller for your application, say MyController, it should
be defined something like this:
MyController.h
@interface MyController : NSObject
{
NSTableView * myTableView1;
NSTableView * myTableView2;
// other instance vars
}
If you created the correct outlets in IB, then myTableView1 and myTableView2
are essentially pointers to NSTableView Objects. When you get the call to:
- (int)numberOfRowsInTableView:(NSTableView *)theTableView
theTableView parameter is a pointer to one of the NSTableView Objects, so
you can just compare the pointers to see which object it points to, for
example:
- (int)numberOfRowsInTableView:(NSTableView *)theTableView
{
if (theTableView == myTableView1)
do something;
else if (theTableView == myTableView2)
do something else;
}
Joe Schiwall
MacTelligence.com