Mac OS X Reference Library Apple Developer Connection spyglass button

Version: 1.0

Posted: 2009-05-27

Build Requirements: Xcode 3.2 or later, Mac OS X v10.6 or later

Runtime Requirements: Mac OS X v10.6 or later

View Source Code:

Download Sample Code (“TemperatureConverter.zip”, 27.5K)



Description

A simple example using NSValueTransformer to automatically convert data between different representations. The purpose of this example is to show how to create and use custom NSValueTransformer subclasses. Otherwise it is possible to create a temperature converter using "regular glue code" with less lines of code.

Temperature Converter presents a simple user interface through which the user can enter temperature values in any of four different units and the application will automatically convert and display the temperature in the other three units. The four units are Kelvin, Centigrade, Fahrenheit, and-- the infrequently used-- Rankine temperature scale.

Internally, the application stores temperature values in Kelvin and uses value transformers to transform the entered temperature value to Kelvin and then from Kelvin to the other scales needed.

Document Revision History

Date Notes
2009-05-27A simple example using NSValueTransformer to automatically convert data between different representations.
Did this document help you? Yes It's good, but... Not helpful...