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?
Post
Replies
Boosts
Views
Activity
@snuff4 This is indeed from your blog post. Thanks for the update. Sorry I'm replying three months later. 🤪
I'm running into the exact same issue and am a little disheartened to see no one has answered your question in 4 months.
Spotlight seems to only crash when the simulator is open. Opening developer documentation also insta crashed Xcode.