I have a Cocoa app with a similar layout like Mail.app:
- A source list on the left where the user can select one of multiple entries
- A detail table view in the main content area showing a list based on the selected item on the left
I’d like the selection in the detail table view to be maintained separately for each master item.
Currently I have only one detail table view and one array controller. When the master selection changes, I update the contents binding for the detail array controller.
I think I may need multiple detail array controllers — one for each entry in the master list.
Is there an easier way/recommended pattern to do this?
You need an array controller for each table. For each detail array controller, you need to bind the
contentsbinding to theselectedObjectskey of the master array controller.So if you had three array controllers,
master,detail1anddetail2, then thecontentbinding ofdetail1should be set tomasterusing a key path ofselectedObjects.The
contentbinding ofdetail2should be set todetail1, also using a key path ofselectedObjects.You don’t need to change the
contentsbinding programmatically.