Search code examples
iosobjective-clocalenscalendar

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?


Solution

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

    [[NSCalendar currentCalendar] firstWeekday]