【发布时间】:2017-04-22 01:58:53
【问题描述】:
我正在尝试从 NSLocale 打印一些基本信息,但我无法从 .scriptCode 属性中获取值。
目前,相关位是
let localeIdent = NSLocale.autoupdatingCurrent.identifier
let userLocale = NSLocale(localeIdentifier: localeIdent)
let languageScript = userLocale.scriptCode //not sure why this doesn't seem to return anything.
print("Language script code: \(languageScript)")
打印总是返回“nil”。
语言环境为我返回其余的信息集、地区和语言等,所以我不确定为什么不存储/返回。
【问题讨论】:
-
仅供参考 - 在 Swift 3 中使用
Locale,而不是NSLocale。 -
这有什么特别的原因吗?