Hi,

I'm currently learning Cocoa by reading the 3rd edition of "Cocoa
Programming for Mac OS X".
One of the excercise is to create an application to draw ovals.

I ended up with a project like this:
DrawView is a subclass of NSView which is responsible to draw the ovals
MyDocument is a subclass of NSDocuments which holds a NSMutableArray
of ovals + code to load/save the files

I then created an IBoutlet theDoc in DrawView.h to reference the
instance of MyDocument by connecting the File's Owner.
In DrawView, when the user creates an oval (by creating a NSRect with
the mouse), it calls [theDoc addOval:oval].
And in its -drawRect:, it asks the doc for an array of ovals to draw them.

The application is behaving as expected, the model (the ovals) are
kept in MyDocument and the DrawView just draws them.
But I was wondering if that was the "right" Cocoa way to do so, to use
an IBOutlet to connect a NSView to a NSDocument.
Is there another way to have a reference to the document from one view
of the application?

regards,
jeff

-- 
Jeff Mesnil
[EMAIL PROTECTED]
http://jmesnil.net/weblog/
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to