Re: Value Transformer with multiple Model Key Paths
Re: Value Transformer with multiple Model Key Paths
- Subject: Re: Value Transformer with multiple Model Key Paths
- From: Quincey Morris <email@hidden>
- Date: Mon, 31 May 2010 02:57:55 -0700
(reposted to the correct list)
On May 31, 2010, at 01:58, Ken Thomases wrote:
> 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.
That's a neat solution, but to anyone who might actually contemplate using any kind of value transformer in the scenario being discussed, I'd suggest that a value transformer solution has *no* advantages whatsoever, plus several disadvantages, compared to providing a property on the model object, unless:
a. The value transformer is generally useful on objects of a number of different classes, or
b. You can't modify the class for some reason
P.S. It occurs to me that there *is* a flaw in your proposal, isn't there? -- it's not KVO compliant for either of the properties that really affect the intended color. Providing a +keyPathsForValuesAffectingSelf method would work, I guess, but it's quite ugly. And involves the class source code in a way that the whole value transformer thing was trying to avoid.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden