2 TableViews - 1 Controller - Best Practice?
2 TableViews - 1 Controller - Best Practice?
- Subject: 2 TableViews - 1 Controller - Best Practice?
- From: Steve Cronin <email@hidden>
- Date: Tue, 13 Sep 2005 00:00:41 -0500
Folks;
I have a window which will have 2 tableviews.
I have a single appController.
In order to support the datasources for these 2 tableviews I done the
following:
-(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:
(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if ([[aTableView autosaveName] isEqualToString:@"A"]) {
NSParameterAssert(rowIndex >= 0 && rowIndex < [aArray count]);
return [[aArray objectAtIndex:rowIndex] objectForKey:
[aTableColumn identifier]];
}
if ([[aTableView autosaveName] isEqualToString:@"B"]) {
NSParameterAssert(rowIndex >= 0 && rowIndex < [bArray count]);
return [[bArray objectAtIndex:rowIndex] objectForKey:
[aTableColumn identifier]];
} else {
NSLog(@"Unexpected tableView: %@,[aTableView autosaveName]);
return [NSString stringWithString:@"Unexpected tableView"];
}
}
I know that efficiency is really paramount here (isn't always?) so:
1) is the NSParameterAssert useful or necessary? Does Cocoa itself
make it unnecessary?
2) Is there a way to generize the code by getting the datasource
array from aTableView so I wouldn't have to hard code those values?
3) Is the autosaveName a reasonable way to distinguish them?
4) Am I way out in the weeds and there is just a much better way to
do this?
Thanks in advance!
Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden