• 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: Apple MVC and Document Based application confusion.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple MVC and Document Based application confusion.


  • Subject: Re: Apple MVC and Document Based application confusion.
  • From: Jason Stephenson <email@hidden>
  • Date: Sun, 29 Nov 2009 20:04:44 -0500

Sandro Noël wrote:
Hello.

I'm reading COCOA Design Patterns from Eric M. Buck & Donald A. Yacktman.
and i'm having a hard time applying the principle in my architecture.

for example, if i create a new document based application in XCode, the MyDocument xib file binds the window outlet to the MyDocument Class.

NSDocument and the document-based architecture in Cocoa is a bad example of MVC. By default when creating a document-based application in Xcode, you get what I like to call MC-V where the model and controller are wrapped up in one object. This is very often easier to implement in a standalone application where you do not expect to reuse the data model class, ever, than is a more traditional MVC approach.


Personally, I prefer to add a NSWindowController subclass for my document and make that the File's Owner in the nib/xib. I also don't start with the document-based application template, but instead start with a straight Cocoa application and then add my NSDocumentController, NSWindowContoller, and NSDocument subclasses.

I have not yet needed a NSViewController subclass, but my NSWindowController subclass typically fills that role since it generally has the NSView subclass as an outlet and manages whatever needs managing in the particular app.






From what I read the MyDocument Class is supposed to be a model controller, not the window controller.
The MyDocument Class is supposed to be able to host an array of window controllers.
I see that makes sense if I have a main data view window and I would want to associate an inspector to that window and share the same data source with both windows. and I like that idea.
what i am unsure of is how to go about with interface builder, and where should i associate the view with it's controller
inside the MyDocument Class? ( but i read that model should have no knowledge of the view)
is it the same for the Model Controller?


if it's not then MyDocument Class becomes more than a Model Controller it is also a Window controller.
in witch case why bother creating separate View/Window controllers?
and why host an array of window controllers?

Do i create the Window controllers in IB or do i do it in code, and how would i go about doing that the right way?

Have you read this?

http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Documents.pdf

It might prove helpful.


I'm kind of confused and I'd really love some clearing up.

thanks for any pointers.
Sandro Noel._______________________________________________

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

_______________________________________________

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: Apple MVC and Document Based application confusion.
      • From: Graham Cox <email@hidden>
References: 
 >Apple MVC and Document Based application confusion. (From: Sandro Noël <email@hidden>)

  • Prev by Date: Re: I can't supply document reference to (init) with bindings, can I?
  • Next by Date: Re: RGBA UIColor Information At CGPoint?
  • Previous by thread: Apple MVC and Document Based application confusion.
  • Next by thread: Re: Apple MVC and Document Based application confusion.
  • Index(es):
    • Date
    • Thread