Q:

How to format a Swift 3 nsmeasurement string to at most 2 decimal places after conversion?

I would like to know how to round nsmeasurement after conversion from a unitmass. From Kilograms to Pounds for example and rounding to the 2nd decimal place instead of giving me the exact.
 var x = Measurement(value:19, unit: UnitMass.kilograms)
 x.convert(to:UnitMass.Pounds)
 x.description // "41.8878639834918 lb"

I'd like it to be 41.89 

A:

By using a MeasurementFormatter:
var x = Measurement(value:19, unit: UnitMass.kilograms)
x.convert(to:UnitMass.pounds)
x.description // 41.8878639834918 lb

let n = NumberFormatter()
n.maximumFractionDigits = 2
let m = MeasurementFormatter()
m.numberFormatter = n
m.string(from: x) // 41.89 lb

