I have a non document-based Core Data application. There's an NSTreeController that manages a collection of objects displayed in a single NSOutlineView as a source list. They are the usual kinds of things: headings, folders, smart folders, etc.
Each of these container objects has a collection of contents objects. I have three separate view controllers that display these objects in various ways (an NSTableView and two custom graphical views, if you really want to know) But these are really just three different presentations of the same data. They should always show the same objects, share the same selection, etc.
I'm also using a hierarchy of NSViewControllers to manage my views. (If I'd known about Cathy Shive's excellent KTUIKit at the time, I would have used that, but my view controllers are very similar to -- and very much inspired by -- hers)
As it stands now, I have an NSTreeController living in the view controller for the source list view. I also have an NSArrayController in each of the sub-view controllers which is bound to the NSTreeController via some overly-complicated keypaths.
So, what needs to change, in my opinion, is the following:
- The
NSTreeControllerneeds to move out of the outline view's controller. - There ought to be a single
NSArrayControllerthat each of the contents views can be bound to instead of three separate ones. Although I'm less certain of this point.
What I'm having difficulty with is figuring out where these things should live. I'm having a hard time deciding which objects, if any, truly "own" the various controllers. Do the parent view controllers own it? Does the window controller? As this is application-level data, do I go so far as to make these owned by the App Delegate? (I could imagine a circumstance where a use might want to open multiple windows, although that's not currently supported) What does the StackOverflow hive mind think?