December 2016
Intermediate to advanced
416 pages
15h 21m
English
With the basics of the interface wired up, let’s implement the conversion from Fahrenheit to Celsius. You are going to store the current Fahrenheit value and compute the Celsius value whenever the text field changes.
In ConversionViewController.swift, add a property for the Fahrenheit value. This will be an optional measurement for temperature (a Measurement<UnitTemperature>?).
@IBOutlet var celsiusLabel: UILabel! var fahrenheitValue: Measurement<UnitTemperature>?
The reason this property is optional is because the user might not have typed in a number, similar to the empty string issue you fixed earlier.
Now add a computed property for the Celsius value. This value will be computed based ...
Read now
Unlock full access