On Sep 29, 2009, at 15:15, Chase Meadors wrote:

I'm having some conceptual trouble concerning using multiple windows with multiple controllers in a project. Where exactly is the line as to what a window controller subclass should manage, and what the App controller should manage?

Say I have a window with a fair amount of controls and setup required, so I create a window controller that manages it. I implement awakeFromNib on it to do the setup, and it implements any IBActions needed for controls in that particular window.

My app controller contains properties that are needed by every window in the app for modification or bindings. It seems to me, to avoid mixing windows with other controllers than their own, that I should declare an IBOutlet id mainAppController in each of the window controllers, and modify/bind to properties in the app controller by binding to myController.mainAppController.aProperty.

There's nothing obviously wrong with this. If it's window specific, the window controller should take care of it. If it's not window specific (and common to all windows), a singleton controller should take care of it.

However, I think you might be focused too much on controllers, and not enough on data models. Unless your requirements are very simple, you might want to move the application-wide properties to a singleton data model object (or object hierarchy).

Similarly, you should consider whether you should move the properties that individual windows depend on to data model objects. If you can conceptualize opening multiple windows on the *same* data (whether or not you ever actually intend to do that), then you probably need to abstract your data model from your window controllers.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to