In my interface I need to provide two NSTableViews in the same window that are structurally the same, but present different data to the user. I'm using storyboards and to do this, I've placed two Container Views in the view controller of the window. I then added a single view controller to the storyboard (outside of the window's view controller) and into that controller placed an NSTableView.
A couple of storyboard screenshots to illustrate:
The NSTableView is inside the Lineup View Controller, which has its own interface and implementation. The two Lineup View Controllers are binded to the container views within viewDidLoad of the Game Board View Controller like so (showing the code for only one of the attachments):
homeLineupView = [self.storyboard instantiateControllerWithIdentifier:@"Lineup View"];
[self addChildViewController: homeLineupView];
[HomeLineupContainerView addSubview:homeLineupView.view];
I'm able to successfully populate the two table views using notifications to provide the data that is unique to each table. The table views are functioning independently, as expected, with no problems.
Where I'm kind of stuck is how I now go about talking to the two table views from the view controller that manages everything else in the window (Game Board View Controller in the second figure). For example, how would I go about telling the table view inside Home Lineup Container View to select row 3? I have references to the Lineup View Controllers, but not the NSTableViews — unless there is a straightforward way to get those so I can call the methods directly. Or... do I need to set up notifications (or some other mechanism) for doing things like selecting a row, detecting a double click, etc?
Thanks!!
Adding a little more information about where I am confused
When I step through my code in the debugger I can "see" the table view inside the NSViewController that references the enclosing container view (see below).
You can also see my very incorrect attempt at using tableView directly to selectRowIndexes. 'visitorLineupView' is defined like so:
@interface GameBoardViewController : NSViewController <NSOpenSavePanelDelegate> {
:
:
NSViewController *visitorLineupView;
NSViewController *homeLineupView;
:
:
}
And the tableview itself is defined like so:
@interface LineupViewController : NSViewController <NSTableViewDataSource> {
:
:
IBOutlet NSTableView *tableView;
:
:
}
So, the procedural C programmer in me sees all this and wants to grab that 'tableView' pointer and use it directly to send it 'selectRowIndexes' message. But I know that conceptual rules of MVC are throwing up roadblocks I'm having a difficult time scaling.