0

There is a calendar setting in iOS that allows the user to change on what day the week-based calendar begins. I display a calendar in my app and want to be able to leverage this setting so the layout of my weekday columns matches those of the first party Calendar app.

Is there a way to do this? I've tried tapping the .firstWeekday property of NSCalendar but it always returns 1, regardless of setting.

Ricky
  • 3,101
  • 1
  • 25
  • 33
  • 1
    Have you checked [this approach](http://stackoverflow.com/a/27153293/4108415)? – Ivan Nesterenko Mar 15 '16 at 00:42
  • @IvanNesterenko I was hoping for an approach that didn't require me to use a reference date. – Ricky Mar 15 '16 at 00:50
  • I'm new to programming so this may not be helpful. I think your assumption is wrong, and I think Ivan was getting at that as well. Namely, the weekday property of `NSCalendar` is always the same (i.e. for the Gregorian calendar, the weekday property of NSDateComponents is always 1), so you're trying to tap into the wrong property. It'd be good to know what you do need to tap into (I don't recall seeing it referenced). But from a user experience view I would make it a 'setting' within your app so the user can set it how they want, rather than assuming they want it to match their iOS settings. – Monomeeth Mar 15 '16 at 01:41

1 Answers1

0

Change your phone's region and try this:

let firstWeekday = Locale.current.calendar.firstWeekday
print(firstWeekday)

The console prints 1 when the region is en_US and 2 for en_FR (France), which correspond to Sunday and Monday respectively.

blwinters
  • 1,911
  • 19
  • 40