I'm having problems to declare/use a zero symbol for an unknown value when using MeasurementFormatter:
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.zeroSymbol = "?"
numberFormatter.string(from: 0.0) // '?'
let formatter = MeasurementFormatter()
formatter.unitOptions = .providedUnit
formatter.numberFormatter = numberFormatter
var distance = Measurement<UnitLength>(value: 0, unit: .parsecs)
formatter.string(from: distance) // '0 pc' - expected: '? pc'
Trying different declarations of the value such as Double.zero doesn't change the output.
Is this a conceptual thing in iOS or am I missing something here?
It turned out to produce the desired output by changing the Measurement declaration (
distance):A radar is filed.