I have the following models in my application.
Board
, holds a NSMutableArray property lists
of type List
belowList
, holds a NSArray property cards
of type Card belowCard
, has a NSString property name
The relationship is thus Board --> to-many List --> to-many Card
I have a NSCollectionView based master-detail interface working. In the detail interface I have an NSTableView that I wish to populate.
BoardArrayController -> bound to File's owner
ListArrayController -> bound to BoardArrayController.
CardArrayController -> bound to ListArrayController
The master collection view has the Content bound to BoardArrayController
** Controller key: arrangedObjects
** SelectionIndexes is also bound to BoardArrayController.
The detail collection view has the Content bound to the ListArrayController
The NSTableView's column (in the item prototype) is bound to CardArrayController
The detail interface's NSTableView is being populated with the correct number of cards for a certain list. However, the cell title is empty. I can click on the rows and see the selection, but no text unfortunately.
There are multiple table views, one for each item in the detail collection view, right? And the content of each table view should reflect the cards for the list it represents. The content of the various table views should not be affected by which list is selected.
Since there should be multiple table views with independent content, they can't all be bound to a single array controller. You want multiple CardArrayControllers, one for each item in the detail collection view (a.k.a. each List).
The easiest way to do this is to move the collection view item view into its own NIB. The collection view item in the first NIB should be configured with the NIB name of this secondary NIB I'm describing. It's view outlet should not be connected to anything.
Configure the class of the File's Owner placeholder in the secondary NIB to be NSCollectionViewItem
, since that's what will load and own it. All bindings in this NIB should go through the representedObject
property of that placeholder object. There should be an array controller in this NIB, basically what you currently have as CardArrayController. Its content would be bound to File's Owner.representedObject.cards.
So, each List for the selected Board has a corresponding item in the detail collection view. That item has its representedObject
set automatically to that particular List it's representing. The collection view item will load the secondary NIB to construct its view. That NIB will have both a view (including a table view) and an array controller for the Cards of that List.
Now, bind the table view column (in the secondary NIB) to the CardArrayController (in that same NIB). That's assuming that you're using an NSCell
-based table view. If you're using a view-based table view, you need to set up bindings differently.