Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLocaleUsesMetricSystem always YES on iPad

I am trying to decide if the users Region/Locale settings validates the use of Metric values (in this case if kg or lb should be appended).

I am running 3.2 on my iPad and on the simulator(Xcode 3.2.4). I have tried out a few different Region settings but I simply can not make it return NO for NSLocaleUsesMetricSystem

NSLocale *locale = [NSLocale systemLocale]; 
BOOL usesMetric = [[locale objectForKey:NSLocaleUsesMetricSystem] boolValue];

NSLog(@"The system is Metric: %@\n", (usesMetric ? @"YES" : @"NO"));

This even happens for language set to English and region set to United States on both the simulator and on the actual device.

I also tried NSLocaleMeasurementSystem and it too always returns "Metric", never "U.S.".

How will I go about deciding if I should use Metric or not?

Thanks for any help given:)

...could I be so lucky that the whole world changed to metric while I was sleeping:)

like image 222
RickiG Avatar asked Oct 20 '10 13:10

RickiG


2 Answers

Try currentLocale instead of systemLocale

like image 83
Stefan Avatar answered Oct 21 '22 04:10

Stefan


Had the same problem, until I realized, that UK officially uses metric system. I have always thought that they still use imperial, so I tested with UK.

As soon as I started to test US locale, NSLocaleUsesMetricSystem started to return "NO" as expected.

Hope this helps.

like image 2
Vilém Kurz Avatar answered Oct 21 '22 04:10

Vilém Kurz