gpt4 book ai didi

ios - NSLocale 强制日历类型

转载 作者:行者123 更新时间:2023-11-29 01:35:48 27 4
gpt4 key购买 nike

[NSLocale currentLocale]可能会返回<__NSCFLocale: 0x7ff708516540> 'en_US@calendar=japanese'}

问题:我可以说 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);

输出类似

enter image description here

swift

var lang = NSLocale.preferredLanguages()[0]

let langua = NSLocale.currentLocale().objectForKey(NSLocaleLanguageCode) as! String
let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String

关于ios - NSLocale 强制日历类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32986395/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com