Anyone else seeing an issue where the formatted temperatures are not rounding in Mac build? iOS build works fine. What am I missing?
Mac:
iOS:
Code:
weather.currentWeather.temperature.formatted(.measurement(width: .narrow))
Anyone else seeing an issue where the formatted temperatures are not rounding in Mac build? iOS build works fine. What am I missing?
Mac:
iOS:
Code:
weather.currentWeather.temperature.formatted(.measurement(width: .narrow))
I have not tested, but I wonder if .narrow deals with the unit format and not the value ? Could you show the code that displays the value ?
Thanks for helping Claude, the code there actually also shows the value in addition to the ° symbol. The .narrow just takes away the localized label, i.e. "F or C". taking out the .narrow would write 99°F for instance. Taking away the .formatted() option leaves the raw NSMeasurement object. You can add .description to the end of the temperature, and it will return the value in Celsius, but this description cannot be formatted from what I can find. Which is what led me to the code below.
Hope that helps. Thanks again.
The full code to write that text is
Text("\(weather.currentWeather.temperature.formatted(.measurement(width: .narrow)))")
.font(.system(.largeTitle, design: .rounded))
.fontWeight(.bold)
.foregroundColor(Color.white)
Looks like this may have been a bug with MacOS 13. After going into Settings > General > Language & Region, and setting Temperature units to C and then back to F, it works just fine.