On May 30, 2010, at 11:46 PM, Quincey Morris wrote: > On May 30, 2010, at 18:11, Markus Spoettl wrote: > >> What I usually do in such situations is create an artificial property on the >> model object that combines the state of multiple properties into one value. >> In your case that properties could return >> >> (a) another value that you transform into a color or >> >> (b) it could return the color directly. >> >> I know that violates the MVC paradigm, but it's a very simple and efficient >> solution - meaning least amount of code necessary. > > Your two proposals are both viable, and, in fact, neither of these solutions > violates the MVC paradigm in any way. The property that you create doesn't > add any knowledge of the actual UI to your data model, nor does it establish > any special or privileged line of communication between the model and the > view. It's just a property of the model -- "a color suitable for representing > the current state of this object" -- that's available to any "client" of the > model for whatever purpose. The returned color could (for example) be used as > a key to a NSDictionary, if that happened to be useful somewhere else in the > application. > > If having a color property is nevertheless distasteful, solution (a) is an > equally valid alternative.
I haven't tested to be sure, but I believe there's a third possibility. You can make the model key path "self" and write the value transformer to transform from the the whole object to a color. It can inspect multiple properties of the object to accomplish that. Cheers, Ken _______________________________________________ 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