Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

iphone - NSLocale preferredLanguages objectAtIndex:0 always return "en"

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

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

Here is screenshot

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!

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

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

Why so weird? Does anybody have such problems?

Updates: 1

  • Delete Xcode as well as simulators, and reinstall it by downloading from Mac Store.
  • Create a new simple project, change simlulator's language
  • Still get always "en".

Oh! What's wrong....


Updates: 2

  • 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!

Why still only one "en" could be found? Where are Japanese and English?

What happened to simulators?

Is there anything I missed?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

See this answers:

iOS8.1 Simulator always uses US keyboard layout despite german hardware keyboard

and this:

iOS 8.1 Simulator Localization broken (NSLocalizedString)

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

Best, gigi


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...