开发者

NSLocaleUsesMetricSystem always YES on iPad

开发者 https://www.devze.com 2023-01-21 03:08 出处:网络
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 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:NSLoc开发者_运维问答aleUsesMetricSystem] 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:)


Try currentLocale instead of systemLocale


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号