0

In this question an excellent step by step list shows how to bind an entity to a view controller (in MacOS, not iOS).

Step be step instruction to binding array controller to core data and view controller.

I can't seem to find the same for a Master/Detail arranagement where I would start with the same steps listed in the other question and then connect another array controller to another entity that contains the detail data for the item selected in the master array controller.

Can someone provide a concise "simple" example?

Community
  • 1
  • 1
  • Is the detail table view in the same view controller? – Willeke Apr 06 '17 at 23:40
  • There is a tab view controller, the first tab is for master selection and editing, the remaining tabs display various child properties of the master. It is a story editor, master is story entity - name, author, summary, pitch, etc. Another tab might be characters, name, background, personality, etc. Each story would/could have it's own set of characters, or some characters could be shared in multiple stories. So, the master would be in one tab, and the children would be in separate tabs, they all share the same tab controller, but separate view controllers. Each would have it's own entity. – Frank Nichols Apr 07 '17 at 21:07
  • Here's a similar problem: [Using an NSArrayController in Multiple Storyboard Scenes](http://stackoverflow.com/q/26748148/4244136). – Willeke Apr 08 '17 at 14:30
  • Thank you, I saw that and I am having trouble converting it to core data. I don't understand how to sync the "Add" button on both Array controllers, and I don't understand what my content is bound too for the detail array controller in the case of persistent store. I feel like an idiot, it seems this is an extremely simple thing, and I am new and can't figure it out. Google doesn't help much since 99% of all core data master/detail examples on the internet are iOS based. It is almost like MacOS has been abandoned to only those that already know how to program in it. – Frank Nichols Apr 08 '17 at 22:09
  • I'm familiar with array controllers and Core Data but I'm struggling with storyboards. This isn't an extremely simple thing. I'll write an answer. – Willeke Apr 09 '17 at 08:48
  • Thank you, I look forward to it. – Frank Nichols Apr 09 '17 at 15:06

1 Answers1

0

Connecting another array controller to another entity that contains the detail data for the item selected in the master array controller is easy. Bind Content Set of the detail array controller to the master array controller, Controller Key selection, Model Key Path characters (the children relationship). However, this isn't easy if the array controllers aren't in the same view controller.

Solution A: Put the master array controller in the tab view controller. Xcode Bind a Text Field to the Selected Item in a Table View From a Different ViewController

Solution B: Put a mirror master array controller in the details view controller. Using an NSArrayController in Multiple Storyboard Scenes make sure the master array controllers stay in sync.

Solution C: Bind the details array controller to the master array controller in code.

And other solutions.

Community
  • 1
  • 1
Willeke
  • 14,578
  • 4
  • 19
  • 47