0

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?

patrickS
  • 3,590
  • 4
  • 29
  • 40

1 Answers1

2

Use Locale usesMetricSystem.

if Locale.current.usesMetricSystem {
    // liter
} else {
    // gallon
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579