[NSLocale currentLocale]
可能会返回<__NSCFLocale: 0x7ff708516540> 'en_US@calendar=japanese'}
问题:我可以说NSLocale不会将calendar=japanese
附加到区域设置。
答案 0 :(得分:1)
<强>目标C 强>
NSString *lang = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLog(@"language is %@", lang);
NSString *langua = [[NSLocale currentLocale] objectForKey: NSLocaleLanguageCode];
NSLog(@" specified language is %@", langua);
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
NSLog(@"specified countryCode is %@", countryCode);
输出如
<强>夫特强>
var lang = NSLocale.preferredLanguages()[0]
let langua = NSLocale.currentLocale().objectForKey(NSLocaleLanguageCode) as! String
let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String