Reputation: 26476
I really hope someone can help on this because I'm learning cocoa and have hit a road block.
I am trying to model a simple poker tournament. For now, my entities are simply a Tournament (with a number) and a Player (with a Name). A Tournament has an array of Players.
I can bind two independent table views to display the tournaments and the players just fine. But I want the players table view to just show the players that belong to the selected tournament from the first table view.
Each has it's own array controller. I have tried a variety of different bindings for the second (players) table but to no avail. Has anyone accomplished this? If so maybe you could spell it out for me, as I there are few examples online.
I have the bound the column in the players table view to this second Player AC, controller key arranged objects. But what to put in the Model Key Path? I know it is working because if I stick @count in there I get the correct number of players for the selected tournament. But 'name' and 'player.name' are no good. Is there any kind of 'item.name' or 'players.item.name' I can try?
Sooo close, thanks for the help so far:
Upvotes: 3
Views: 2042
Reputation: 26476
I found the answer here:
Implementing parent->child drill down in Cocoa with Core Data bindings that span multiple entities.
I'm surprised this is not a more commonly used practice, and hope the next person reading this doesn't spend so long finding the answer!
Upvotes: 0
Reputation: 816462
I think this tutorial will help you. They also create a master/detail view.
In short: Bind the contentArray
of your player's array controller to the tournament's array controller, set ControllerKey
to selection
and the remaining properties accordingly to your model.
Upvotes: 4