On Mon, Nov 9, 2009 at 5:04 PM, Oftenwrong Soong <oftenwrongso...@yahoo.com> 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? For sufficiently complex views, I sometimes find it useful to design a "view model" that contains information specific to the display of the data. For example, information about X/Y positions, distances between different parts of a view, click counts, and measurements probably don't belong anywhere in your business/data/domain model, but your view will need to store this information somewhere both to read from it and, occasionally, to write to it. Simpler views can just keep this information within themselves as discrete instance variables, but when this becomes unwieldy, using a structure like a view model can help keep this data organized and even help you in conceptualizing what's going on in your view. e _______________________________________________ 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