NSLocale preferredLanguages objectAtIndex:0总是返回“en” [英] NSLocale preferredLanguages objectAtIndex:0 always return "en"

查看:1358
本文介绍了NSLocale preferredLanguages objectAtIndex:0总是返回“en”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Simulator的语言已经改为日语,为什么 [[NSLocale preferredLanguages] objectAtIndex:0] 总是返回en

Simulator's language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0] always return "en"?

首选语言和地区都与en无关,en来自哪里?

Neither preferred language nor region is related to "en", where does "en" come from?

试图获得 [[NSLocale preferredLanguages] objectAtIndex: 2 ] ,然后崩溃显示 ***由于未捕获的异常'NSRangeException'终止应用程序,原因:' - [__ NSCFArray objectAtIndex:]:index(2)超出范围(1)

Tried to get [[NSLocale preferredLanguages] objectAtIndex:2], then crash shows *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (2) beyond bounds (1)

这是否意味着模拟器中没有设置任何语言?太奇怪了!

Does it means there is no any languages are set in simulator? So weird!

在用iOS8.1 / 7.1升级到Xcode 6.1之前从未发生这种情况。

This never happened before upgrading to Xcode 6.1 with iOS8.1/7.1.

同时,在我的iPhone 5上试过同样的东西,控制台输出正确的东西。

Meanwhile, tried same thing on my iPhone 5, console output correct thing.

为什么这么奇怪?有没有人有这样的问题?

Why so weird? Does anybody have such problems?


  • 同时删除Xcode作为模拟器,并通过从Mac Store下载重新安装。

  • 创建一个新的简单项目,更改模拟器的语言

  • 仍然总是en。

哦!出了什么问题....

Oh! What's wrong....


  • 今天,通过重新格式化HD重新安装了全新的优胜美地

  • 下载Xcode 6.1

  • 开始一个新的简单默认项目

  • 放置这些代码

  • 更改/添加模拟器语言,日语,荷兰语,英语,

  • 运行

  • 哦,天啊!再次只有en,找不到日语和英语!

  • Today, reinstalled brand new Yosemite by reformatting HD
  • Download Xcode 6.1
  • Start a new simple default project
  • Put these codes
  • Change / Add language of simulator, Japanese, Dutch, English,
  • Run
  • Oh, God! Got only "en" again, Japanese and English not found!

推荐答案

这是一个错误。这让我发疯了。
Apple已经知道了。

This is a bug. It was driving me crazy. Apple already knows it.

看到这个答案:

iOS8.1模拟器总是使用美国键盘布局,尽管有德国硬件键盘

这个:

iOS 8.1模拟器本地化损坏(NSLocalizedString)

(在答案中有更改架构的临时修补程序)

(In the answer there is a temporary fix changing the schema)

最好,
gigi

Best, gigi

这篇关于NSLocale preferredLanguages objectAtIndex:0总是返回“en”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆