• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reverse value transformation with different class?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Reverse value transformation with different class?
      • From: Wain <email@hidden>
  • Prev by Date: Re: NSApp sendAction
  • Next by Date: Re: Basic runtime function usage - objc_getClass
  • Previous by thread: Re: Hiding method names in binary
  • Next by thread: Re: Reverse value transformation with different class?
  • Index(es):
    • Date
    • Thread