Swift NSLocale Simulator iOS 8

狂风中的少年 提交于 2019-12-24 13:25:12

问题


I'm having an issue with Swift and the iOS 8 Emulator in XCode 6.1.

Indeed when I try to use NSLocale, almost every functions of it return nil.

Here is how I use it:

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

It does work on device, iOS 7 and iOS 8 and on simulator iOS 7. It doesn't work on simulator iOS 8 and on Playground, it even EXC_BAD_ACCESS. I guess it's just a simulator and Playground problem, but it's weird still. And I wish to know if anyone has a workaround from it.

I did clean derived data, restarted and clean datas of simulator. Not getting better.


回答1:


There is a known issue stated in the release notes of Xcode 6.1:

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



来源:https://stackoverflow.com/questions/26603766/swift-nslocale-simulator-ios-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!