• 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: General MVC and ownership question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: General MVC and ownership question


  • Subject: Re: General MVC and ownership question
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 4 Mar 2008 09:05:38 -0800


On 3 Mar '08, at 6:16 PM, Graham wrote:

The question is: would the better design be one-controller-per-view, or a single controller supporting multiple views? In other words should the controller typically associate with a single view or the data model?

Generally there should be a controller per view. This is because the controller directly operates on the objects in the view (it has IBOutlets, in Cocoa terms), and because you might have different kinds of views (like list vs. icon) that require entirely different controller implementations.


The follow-on question would then be: what would be considered the optimal "ownership" relationships between the various objects in the system? Do data models typically own their controllers, or should the controller(s) own the data model?

There's usually a central "document" object that owns the controllers, which in turn own the views. You can think of the document as an über- controller.


Cocoa supports this model via the NSDocument and NSWindowController (and now NSViewController) classes.

Have you considered using GC? I'd recommend it, if your app doesn't have to support 10.4, and if it doesn't depend on 3rd party Cocoa libraries that aren't GC-ready. It makes this stuff so much easier.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

  • Follow-Ups:
    • Re: General MVC and ownership question
      • From: Graham <email@hidden>
References: 
 >General MVC and ownership question (From: Graham <email@hidden>)

  • Prev by Date: Re: Tabless NSTabView IB3 Bug1
  • Next by Date: Re: two table view selection problem
  • Previous by thread: General MVC and ownership question
  • Next by thread: Re: General MVC and ownership question
  • Index(es):
    • Date
    • Thread