• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
2 TableViews - 1 Controller - Best Practice?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: 2 TableViews - 1 Controller - Best Practice?
      • From: Jack Nutting <email@hidden>
  • Prev by Date: Is there a trick to NSTableViews?
  • Next by Date: Re: Semi-OT QuickTime/OpenGL Textures
  • Previous by thread: Re: Is there a trick to NSTableViews?
  • Next by thread: Re: 2 TableViews - 1 Controller - Best Practice?
  • Index(es):
    • Date
    • Thread