Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine first week day in iOS?

I am using Tapku's calendar in my application and I want to determine if the week should start on a Sunday or a Monday depending on the user's settings. I am calling firstWeekday, but for some reason it returns 1 (Sunday) on a device where the built-in calendar starts the weeks on Mondays (and hence it should return 2):

NSCalendar* cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[cal firstWeekday];

Any suggestions as to what I might be missing?

like image 913
Nikolay Spassov Avatar asked Mar 26 '13 20:03

Nikolay Spassov


People also ask

What is Calendar firstweekday?

The first day of the week for the calendar.


1 Answers

Ok, so it turns out this is the correct way of doing it:

[[NSCalendar currentCalendar] firstWeekday]
like image 85
Nikolay Spassov Avatar answered Sep 20 '22 06:09

Nikolay Spassov