The parent-> child implementation will deploy in Cocoa with master data bindings that span multiple objects

I am trying to create a simple interface for my basic iTunes Genre browser-style data model.

I have a model with three objects: Genre <-->> Artist <-->> Album .

I would just like to bind them each to an NSTableView, but it looks like accessing the child relations from NSArrayController does not meet the requirements of KVC. Thus, it is difficult for me to contact the selected Genre objects with the ArtistController.

How do you do this? Is this possible within IB without any custom subclass?

Edit for Posterity: I made some mistakes.

  • The child controller must know about the managed entity through its own binding.
  • The child controller should not be in Entity mode, but should work as an NSMutableDictionary class.
  • And finally, the child controller does not prepare its data. It retrieves it from the parent using the Content Set binding. Use the selection key of the controller and the path of the model key that connects to the children.

uv Brian's answer and this MacResearch tutorial helped identify my mistakes (and what rights I had).

+6
cocoa core-data cocoa-bindings
source share
1 answer

The approach that I will probably take is to have a separate NSArrayController for each kind of table, and then contain the contents of one array controller based on the choice of another.

For example, let's say you have a table view A, which displays a list of available genres, so it has an array controller A, the contents of which are connected to your managed object context.

Then let's say that you have a table view B, which shows the available artists for which genre is selected in table A. This table will have its own array controller B, and the content array for controller B is connected so that the "controller key" the field in IB is set to "select" the controller key A, while the "artists" are the model key (this assumes that your Genre entity has a "many" relationship called "artists" to the Artist object).

Then you can apply the same principle to the third type of table + controller to show albums for the selected artist.

The general term for this type of setup is the โ€œmaster part interfaceโ€ and is described in Apple documents at this link

+4
source share

All Articles