Reading through the first section of the Apple bindings tutorial, they talk about NSValueTransformers and how they could be useful with bindings. Wanting to explore, I read a bit in the documentation for the class, but struggled a before finding this. It was particularly helpful because I'm kind of hazy about class methods. The result is an app that does Fahrenheit to Celsius conversion entirely by the use of bindings and a specialized NSValueTransformer class. It is reversible. Both text fields also have formatters dropped on them. Notice that the name of the transformer in the binding is the class name.
Here is the code:
class PyX2AppDelegate(NSObject): |