问题
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