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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/jason%40sigio.com

This email sent to ja...@sigio.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to