I'd like to find out if the precipitationAmount
is in .millimeters
or something else but the code below don't works. Do you know why?
let dWeather: Forecast<DayWeather>
if dWeather.first?.precipitationAmount.unit == .millimeters {
Text("Millimeters")
}
if dWeather.first?.precipitationAmount.unit == .inches {
Text("Inches")
}
if dWeather.first?.precipitationAmount.unit != .millimeters && dWeather.first?.precipitationAmount.unit != .inches {
Text("Something else")
}
The output in en_UK
and fr_FR
should be .millimeters
and in en_US
should be .inches
but I always get Millimeters
.
SwiftUI as a feature implements localization my default when you use standard formatters such as.
But if you change
.rainfall
to.asProvided
you can see the actual unit from the API.Apple does not specify a unit in the documentation so I would not assume a unit.