Search code examples
iosswiftiphoneswift3calendar

Cannot update calendar firstWeekDay Swift 3.0


I'm trying to update the calendar firstWeekDay to something else (as far as I seen the default firstWeekDay is Sunday) but some errors occur.

private var calendar = Calendar.autoupdatingCurrent
calendar.firstWeekday = 3

// the 2nd line is here only to ask this question on StackOverFlow (is missing on my code because I am want the user to use its own calendar, not something forced by me. Check code+errors screenshot here

Note: I managed to do this at the beginning of the project with the same simple code but after a while I updated the app on my personal iPhone to check how it looks and behave on a real device and I noticed that the the first week day is not Monday anymore as my personal iPhone calendar is set.


Solution

  • I managed to solve the issue. Apparently I had to define a new function and update the firstWeekDay property inside that function. :)