I’ve rebuilt my application to use multiple XIBs backed with their own ViewControllers, largely so that I can swap their respective views in and out of the main application window at need, but have now encountered a design issue I hope someone may be able to help with.
The application’s ManagedObjectContext is loaded in the single App Delegate, and shared by all these views. It also provides outlets for all the ViewControllers and methods for loading their views into the main window. This seems sound.
But each ViewController/XIB has ArrayControllers for the same data, and often, I’m making KVC binding references across the objects to display and manage the data in the various views. And feeling rather dispirited by the amount of typing I’m having to do to maintain these bindings, I began to wonder if I was doing it wrong. (There should be a word for the sense of foreboding inexperienced Cocoa developers get when they think ‘this is all too hard; there must be some better way …’. ;-)
I first thought I should bind an ObjectController in the display XIB to the selected object from the pick list in the parent XIB, something like
objectController Value: delegate...selection
but I couldn’t get the values in the fields bound to the objectController to update properly. I spent the whole day working on it, reading and and trying to figure it out, but to no avail, and abandoned the approach.
So now I’m simply binding the text fields in one XIB to edit an object’s values selected from the arrayController in another XIB like this:
Text Field Value: delegate...selection.
And it works, but if I’m going to do that, why not put the arrayControllers into the main XIB, provide outlets, and just reference them more directly; why bother putting them in the other XIB in the first place?
But something tells me I’ve got it all wrong. So I watched Lord of the Rings for a bit, as you do, and then thought Marcus and the lads would know the answer. So … can anyone help with this, please?
I want to reference various ArrayControllers from discrete XIB/ViewControllers; where should those ArrayControllers go?