Saturday, September 2, 2017

Here is the sample code for how to use Measurement in Swift for kg to lb (i.e. Metric to Imperial )

var weight = 20.6
var weightToBeConvert = Measurement(value: weight, unit: UnitMass.kilograms)
weightToBeConvert.convert(to: UnitMass.pounds)
weight = weightToBeConvert.value

Measurement is available from iOS10 +

No comments:

Post a Comment