0
[NSLocale currentLocale]
可以返回<__NSCFLocale: 0x7ff708516540> '[email protected]=japanese'}
NSLocale強制日曆型
問:我可以說NSLocale不追加calendar=japanese
到語言環境。
[NSLocale currentLocale]
可以返回<__NSCFLocale: 0x7ff708516540> '[email protected]=japanese'}
NSLocale強制日曆型
問:我可以說NSLocale不追加calendar=japanese
到語言環境。
Objective-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
謝謝!工作就像一個魅力 – Arsen
非常感謝我的朋友,有一個愉快的一天 –