Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to bind to reverseTransformedValue: in IB



Kyle,

Thanks for the response. I understand what a value transformer is, and I've actually implemented -allowsReverseTransformation and - reverseTransformedValue in all three of my transformers. The transformers are:
• Binary --> hex
• Binary --> decimal
• Hex --> decimal


Thanks to your explanation, I now see that I should have structured the transformers a little differently, and I might go back and rework them (or at least swap the -reverseTransformedValue and - transformedValue methods). But for simplicity's sake, is it possible to accomplish what I was originally asking -- to set up the binding to use -reverseTransformedValue instead of -transformedValue, and vice- versa?

Thanks again,

Sam


On Jan 26, 2008, at 7:25 PM, Kyle Sluder wrote:

A value transformer is essentially a function which maps values of one
type to values of another type.  If you can supply the inverse
function as well, then you do so using -allowsReverseTransformation
and -reverseTransformedValue:.  This allows Cocoa to use your value
transformer to set values as well as transform them, but the reverse
transformation is actually a function (in the mathematical sense).

So for your app, you would probably want to store an NSNumber as your
model.  Then, you would have three value transformers that would
essentially be the following functions: Number --> String (base 10),
Number --> String (base 16), Number --> String (base 2).  You would
provide the reverse transformations in these value transformers as
well, since there is a functional relationship between a string of
digits and a number.  Cocoa will use the model type --> view type
binding (Number --> String) for display, and then use the inverse
(String --> Number) for storage.

So your question about "binding reverseTransformedValue" doesn't make any sense.

HTH,
--Kyle Sluder

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Trying to bind to reverseTransformedValue: in IB (From: Sam Stigler <email@hidden>)
 >Re: Trying to bind to reverseTransformedValue: in IB (From: "Kyle Sluder" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.