Re: Reverse value transformation with different class?
Re: Reverse value transformation with different class?
- Subject: Re: Reverse value transformation with different class?
- From: Wain <email@hidden>
- Date: Wed, 23 Nov 2005 19:26:13 +0000
- Resent-date: Wed, 23 Nov 2005 19:45:59 +0000
- Resent-from: Wain <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: Cocoa mailing list <email@hidden>
I'll agree that the documentation is a little misleading and the
stock example is very simple.
Let's look at two differing examples:
http://www.cocoalab.com/developer/classes/valuetransformers.htm
The link to download the source is broken so use:
http://www.cocoalab.com/developer/classes/CLValueTransformers.zip.bin
specifically CLStringNumberValueTransformer
and closer to home look at RelationshipTransformer which should be in
you Developer/Examples/Sync Services/MediaExample/
SyncExamplesFramework folder
There may be some better examples but this is what I could lay my
hands on quickly...
Wain
On 23 Nov 2005, at 18:11, Tom Harrington wrote:
On 11/23/05, Wain <email@hidden> wrote:
On 23 Nov 2005, at 17:20, Tom Harrington wrote:
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.
This is possible, look at:
http://developer.apple.com/documentation/Cocoa/Conceptual/
ValueTransformers/index.html
Specifically the "Writing a Custom Value Transformer" section.
That's the part I was looking at.
I would suggest however that you simply convert the NSColor to NSData
and back, it's much easier...
I know, but I have other requirements where I really need a string
representation. I didn't just dream up the conversion to string. :-)
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."
The documentation actually states: "Returns the class of the value
returned by the transformer. Subclasses should override this method
and return the appropriate class."
The whole point is to transform from one type to another. :-)
The documentation for NSValueTransformer says that. But the "Value
Transformers Programming Guide" at
<http://developer.apple.com/documentation/Cocoa/Conceptual/
ValueTransformers/Concepts/CustomTransformer.html#//apple_ref/doc/
uid/20002167>
reads as I quoted above, which is why I asked about it.
--
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