Figure out which UnitType (liter / gallon) is the systems default

122 views Asked by At

Is there any way to figure out which UnitType is the systems default based on the systems locale?

I have an UITextField where a user can input an amount of water. I want to figure out if the input is in liters or gallons, so I can setup a correct Measurement().

Or is it in general better, that the user can set this in the settings of the app?

1

There are 1 answers

0
rmaddy On

Use Locale usesMetricSystem.

if Locale.current.usesMetricSystem {
    // liter
} else {
    // gallon
}