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: Lucas Haley <email@hidden>
- Date: Wed, 5 Feb 2003 21:22:34 -0800
Heya --
I'm a relative newbie myself, but I thought I might take this
opportunity to throw down for the first time.
One of the simplest ways is to set up a connection to the table from
your controller, and to compare the two -- make an IBOutlet to the
NSTableView, and compare it with the NSTableView from the method call.
So, in the controller .h file, you have:
IBOutlet NSTableView *tableOne;
IBOutlet NSTableView *tableTwo;
and in the table calls, you might have:
if ([aTableView isEqualTo: tableOne])
{
do something
} else {
do something else
}
The app I'm trying to make has a _bunch_ of tables, and to save some
time I have a #DEFINE that helps me (though it might ruin me later!).
Basically, in InterfaceBuilder, each table column has an Identifier.
For each column, I use an identifier like:
attributes.name
where the first word is the name of the data structure (I'm using an
array) in the model, and the second is the variable I want. Then I have
this #DEFINE:
#define PARSE_ID \
NSArray *keyValue = [[aTableColumn identifier]
componentsSeparatedByString:@"."]; \
NSString *arrayName = [keyValue objectAtIndex:0]; \
NSString *key; \
NSMutableArray *tableArray = [model valueForKey:arrayName]; \
if ([keyValue count] > 1) {key = [keyValue objectAtIndex:1];} \
// NSLog(@"Obtaing data for: %@", arrayName); \
NSAssert(tableArray != nil, @"Could not find appropriate tableView"); \
which grabs the first word, and asks the model for the structure called
"attributes". it then asks the "attributes" structure for a variable
called "name". Its work pretty well for me, as all of my table calls
are the same -- the only differences are coded in IB.
Anyway, its not explained that well, but it might be a start!
- Lucas Haley
----
I think there should be something in science called the "reindeer
effect." I don't know what it would be, but I think it'd be good to
hear someone say, "Gentlemen, what we have here is a terrifying example
of the reindeer effect."
_______________________________________________
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.