My use case for wanting to know what unit a user has selected is to be able to display a toggle that defaults to their selected unit.
I found a hacky way to do this on iOS, but sadly not on macOS.
let temp = Measurement(value: 9, unit: UnitTemperature.celsius)
let formattedTemp = temp.formatted(.measurement(width: .abbreviated, usage: .person, numberFormatStyle: .number))
let unit = formattedTemp.firstIndex(of: "F") != nil ? UnitTemperature.fahrenheit : UnitTemperature.celsius
This code relies on the usage: .person part that seems to format according to what temperature unit the user has selected.
@yvsong Did you ever get a response on your enhancement request?
Topic:
Accessibility & Inclusion
SubTopic:
General
Tags: