I'm going through a refactoring and reorganization of my application at the moment. I've realized that some of the separation between models and views, and their controllers has diminished and I wish to do some cleaning up.
I have several key classes used in my app: NSPersistentDocument, NSWindowController, and a model class.
The NSPersistentDocument class acts as a "model-controller"; it owns an instance of the model class, and manages all interactions with the model.
The NSWindowController class acts as a "view-controller"; it owns the main window, and manages interactions of the views within the main window. This class is also the File's Owner for the nib file in which the Window is defined.
The problem I see here is that I don't have a real "controller". My current design forces the model-controller and view-controller to know about each other. There is no meditating object between the two, and due to this, my model and view are not clearly separated, which makes supporting multiple views or models a problem.
I would like to move functionality from both of my existing controllers into a new "controller" class which would act as a controller between the model-controller and view-controller. In the end, this is still just the MVC design pattern, with just a little more structure.
However, I am having difficulty figuring out how this would fit into Cocoa's document-based app architecture.
The biggest question I have is where and how would this new controller object be created? How does this fit into Cocoa's architecture? Am I fighting against Cocoa's architecture, and is there a better way to do this?
Thanks.