Reverse value transformation with different class?
Reverse value transformation with different class?
- Subject: Reverse value transformation with different class?
- From: Tom Harrington <email@hidden>
- Date: Wed, 23 Nov 2005 10:20:44 -0700
I need to implement a value transformer that will convert a string
representation of a color into an NSColor and back, for purposes of
bindings. The documentation for value transformers seems to indicate
that this is impossible, or at least unsupported, but I'm tempted to
think the docs are mistaken here and I'm hoping someone can clarify
things.
The documentation on writing a custom value transformer says that +
transformedValueClass must return "the class of the object that both
the transformedValue: and reverseTransformedValue: methods will
return." That would imply that a value transformer can only transform
values that are of the same class, and that a reversible NSString <->
NSColor transformer would be right out. If both transformation
methods must return the same class, then reversible transformations
between classes are impossible.
However the pre-defined NSUnarchiveFromDataTransformerName seems to be
doing just that. If my NSColor objects were encoded as NSData, I
could use this transformer, reversibly, even though I'd be converting
between classes.
So, is this kind of transformation legal or not? Are the docs
mistaken, or is NSUnarchiveFromDataTransformerName using some kind of
undocumented Cocoa-fu?
--
Tom Harrington
email@hidden
AIM: atomicbird1
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden