• 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: MVC view/controller separation question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MVC view/controller separation question


  • Subject: Re: MVC view/controller separation question
  • From: Johnny Deadman <email@hidden>
  • Date: Mon, 4 Apr 2005 09:14:55 -0400

The approach I would take would be to have the note objects know how to draw themselves, and have a note manager which manages the notes and tells them when and where to draw, either in or around the textview.

I have something very similar in my app. In this case the structure is as follows

GLPageLayoutView -- responsible for drawing and maintaining the multiple page view of the doc. Only responsible for visuals.
GLTextView -- subclass of NSTextView which manages (only the most) basic user input and display of text.
GLPageLayoutManager -- responsible for co-ordinating the system of Layout Managers, TextViews and Text Containers, and telling the pageLayoutView when and what to draw.
GLInputManager -- delegate for NSTextView which handles sophisticated user input via delegations and notifications
GLNote -- a note which knows how to draw itself in a view
GLDraft -- a draft of the document which knows all about its GLNotes... this is the document model, as opposed to the NSDocument. It is a 'dumb' data object. The NSDocument is its controller.


In this case the pageLayoutManager pulls in the notes, which are 'owned' by the document model... the hierarchy looks like this

The GLNote and GLDraft are models, the things with 'view' in the title are views, and the Manager is the controller.

NSTextView is a little confusing because it feels like a controller in the way it manages user input. However it is important to treat it as a view and not pile responsibilities on it by subclassing. It is better to put the responsibilities either in an NSWindowController or a separate controller... or even several... in my case I created an InputManager which is used to alter the TextView's behavior using delegation.

IMO using coredata & bindings really helps be more rigorous about all this since almost all the code you are writing becomes controller code, so that almost every object you create explicitly is a controller.




On 4-Apr-05, at 6:25 AM, Keith Blount wrote:

My question is simply one of good design: should the
text view be responsible for keeping track of this
array, as it is currently, or should I set up a
NotesController class to handle this that is
instantiated by the text view, and have my text view
call methods on that?

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >MVC view/controller separation question (From: Keith Blount <email@hidden>)

  • Prev by Date: Solved: Need help with undo for text editing
  • Next by Date: RE: MVC view/controller separation question
  • Previous by thread: MVC view/controller separation question
  • Next by thread: RE: MVC view/controller separation question
  • Index(es):
    • Date
    • Thread