我怎么知道iOS上默认的度量系统(英制或公制)? [英] How do I know which is the default measure system (imperial or metric) on iOS?
问题描述
我怎么知道iOS上默认的度量系统(英制或公制)?
How do I know which is the default measure system (imperial or metric) on iOS ?
如何从设备设置中获得此首选项,以便知道在应用程序中显示什么?
How do I get this preference from the device settings, so I know what to display in my app ?
谢谢
推荐答案
NSLocale
可以告诉您:
NSLocale *locale = [NSLocale currentLocale];
BOOL isMetric = [[locale objectForKey:NSLocaleUsesMetricSystem] boolValue];
只有三个国家不使用公制:美国,利比里亚和缅甸.后者使用自己的系统,前两个使用英制.
Only three countries do not use the metric system: the US, Liberia and Myanmar. The later uses its own system, the former two use Imperial Units.
Apple文档说(重点是我):
Apples documentation says (emphasis mine):
NSLocaleUsesMetricSystem
用于指示语言环境是否使用公制的标志的键. 对应的值是布尔值NSNumber对象. 如果该值为NO,则通常可以采用美国的度量单位(例如,法定英里).
The key for the flag that indicates whether the locale uses the metric system. The corresponding value is a Boolean NSNumber object. If the value is NO, you can typically assume American measurement units (for example, the statute mile).
在iOS 2.0和更高版本中可用.
Available in iOS 2.0 and later.
这篇关于我怎么知道iOS上默认的度量系统(英制或公制)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!