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, where I want to display Boards in the master and its corresponding Lists+Cards in the detail view.
The master interface is fine, the elements Board
are displayed nicely.
BoardArrayController -> bound to File's owner
ListArrayController -> bound to BoardArrayController.
CardArrayController -> bound to ListArrayController
The master collection view has the Content bound to BoardArrayController
The detail collection view has the Content bound to the BoardArrayController
Any view element in the prototype views (those that are added with the NSCollectionView) have the following info
The detail interface is not updated when I click a board in the master view. I expect a new set of lists+cards being displayed. It is only the one loaded at startup which is being displayed.
Is this a NSCollectionView selection problem or a binding problem?
Hint: I think it's a binding problem. Because it works, if in my controller I observe masterView.selectionIndexes
and bind an IBOutlet to detailedView
. Then in observeValueForKeyPath:ofObject:change:context:
I manually call detailedView:setContent:
.
Edit: updated setup description in accordance to the answer in Cocoa Bindings for hierarchical model
Finally got an answer from the cocoa-dev mailing list (thanks Willeke).
Solution
The master view selectionIndexes is bound to BoardArrayController. With Controller Key selectionIndexes
.
The detailed view content should then be set to ListArrayController and Controller Key Path arrangedObjects