Question

Is it possible to get firstWeekday depending on location. For instance, in USA it should say Sunday. In Russia it should say Monday.

Edit: [[NSCalendar currentCalendar] firstWeekday] always says 1, but for Russia it should say 2

Était-ce utile?

La solution

Your assumption is wrong. The calendar shouldn't return 1 in USA and 2 in Russia.

First of all, the device never knows in which country it is located. It takes everything from the Regional Settings in the Device Settings. The regional settings are then accessible through NSLocale, e.g. en-US means that USA English settings should be used, including the first week day.

In general, you should just use [NSLocale defaultLocale], which is implicitly set on NSCalendar, NSDateFormatter and similar classes. If you want to simulate the behavior with different language/regional settings, just change them in Device Settings.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top