• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Splitting controller logic
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Splitting controller logic


  • Subject: Re: Splitting controller logic
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 29 Sep 2009 16:31:38 -0700

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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Splitting controller logic (From: Chase Meadors <email@hidden>)

  • Prev by Date: NSLayoutManager and best override point for temporary attributes
  • Next by Date: Re: NSTextField, drawing the text offset to the right in the field
  • Previous by thread: Splitting controller logic
  • Next by thread: Suggestions for debugging “EXC_BAD_ACCESS” - followup
  • Index(es):
    • Date
    • Thread