I live in the Netherlands. We Dutch people like to see Monday as the start of the week. I know that people in the US like to consider Sunday as the start of the week. Silly Americans ;)
If I want to present a week view to my g开发者_JAVA技巧lobal users, can I get the preferred starting day of the week from NSLocale, or is a settings panel the only way to go?
Cheers, EP.
Use the following code:
NSCalendar *calendar = [[NSLocale currentLocale] objectForKey:NSLocaleCalendar];
NSUInteger firstDay = [calendar firstWeekday];
You may also check this relevant question.
The accepted answer is actually incorrect. Here's the correct code:
NSCalendar *calendar = [[NSLocale currentLocale] objectForKey:NSLocaleCalendar];
self.weekStartsOnDay = [calendar firstWeekday];
The issue is that the object referenced by NSLocaleCalendar is actually a calendar.
精彩评论