• 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 and Cocoa text system
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MVC and Cocoa text system


  • Subject: Re: MVC and Cocoa text system
  • From: Jeffrey J Barbose <email@hidden>
  • Date: Tue, 30 Jul 2002 20:27:18 -0700

Try thinking of it this way...

If you wanted to reimplement the application as, say, a web application, would your program still be logically/algorithmically complete in both your scenarios?

As a web app, you would, of course, need a new UI (views) and you'd need modify the controllers only where they talk to the UI.

If you put the action in NSTextView, you'd need to find some other place to put it, because NSTextView is no longer available.

if you put it in a controller, it would stay in the controller even in the web app.

In other words, go with the controllers.

I'm severely paraphrasing, but from Cocoa sessions i've seen, "when in doubt, DON'T subclass a Cocoa class" seems to be the advice apple is giving.

jeff



On Tuesday, Jul 30, 2002, at 19:56 US/Pacific, Eric wrote:

The recent thread on MVC class design got me thinking about MVC separation
in my own app. I have a menu item action connected to the First Responder in
MainMenu.nib. The action method programmatically changes the contents of an
NSTextView.

Currently, I have the action method implemented in an NSTextView subclass. I
subclassed NSTextView for another reason altogether, but I figured since I
already have a subclass, I might as well implement the action method in it.

After reading Apple's documentation on application architecture, which
states that logic specific to an application should be implemented in
controller objects, I'm thinking that the action method should be
implemented in the text view's window controller instead.

What are the advantages and disadvantages of each approach? Implementing the
action method in the NSTextView subclass seems more direct to me, in the
sense that it is the object whose contents need to be changed, so it should
respond to the menu action, rather than waiting for it to travel up the
responder chain to the window controller.

As a side question, should I not be making changes to the text view at the
NSTextView level at all since it is a view object? I.e. Should I subclass
NSTextStorage, NSTextView's model class, and make the changes there?

Can anyone shed some light on this? Thanks.

Eric Wang
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >MVC and Cocoa text system (From: Eric <email@hidden>)

  • Prev by Date: Whoops!
  • Next by Date: NSDocument problem
  • Previous by thread: MVC and Cocoa text system
  • Next by thread: Re: MVC and Cocoa text system
  • Index(es):
    • Date
    • Thread