On Nov 9, 2009, at 3:04 PM, Oftenwrong Soong wrote:

In the MVC style, I want to avoid connecting directly between a view and a model. However I have a custom NSView subclass that renders a graphical view of the model and therefore it needs information from the model. I think it is considered bad practice to put a pointer to the model directly in my NSView subclass. However how can this type of coupling be avoided if the view needs the information?

The following prior post may be of help which discusses the drawing of model objects.

http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg46045.html

On Oct 13, 2009, at 7:58 AM, Erik Buck wrote:

There is ample precedent for adding View specific capabilities to Model objects via categories. AppKit adds string drawing methods to NSString.

You definitely don't want your View subsystem constantly asking Model objects what kind they are in order to present information. If you have ifs or switches based on the class of objects or even based on an attribute of an Entity, you are doing it wrong.

It is much cleaner to use the built in language polymorphism. Just keep View related code implementation within the View.


Richard

_______________________________________________

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