Skip to main content
 首页 » 操作系统

xcode之Swift NSLocale 模拟器 iOS 8

2024年01月01日52leader

我在 XCode 6.1 中遇到 Swift 和 iOS 8 模拟器的问题。

事实上,当我尝试使用 NSLocale 时,它​​的几乎所有函数都返回 nil。

下面是我的使用方法:

let cc = "fr" // Example 
let locale = NSLocale.currentLocale() 
let countryName = locale.displayNameForKey(NSLocaleCountryCode, value : cc) 
println(countryName) // Shows : nil 

它确实适用于设备、iOS 7 和 iOS 8 以及模拟器 iOS 7。 它不适用于模拟器 iOS 8 和 Playground,甚至 EXC_BAD_ACCESS。 我想这只是模拟器和 Playground 的问题,但它仍然很奇怪。我想知道是否有人有解决方法。

我清理了派生数据,重新启动并清理了模拟器的数据。没有好转。

请您参考如下方法:

release notes 中说明了一个已知问题Xcode 6.1 的:

In some situations, [NSLocale currentLocale] may return en_US instead of the chosen locale in the iOS 8.1 simulator. (18512161