Reputation: 13
I currently have an array of weekdays that represent integers which I will trigger a notification on that weekday
let weekdays:[Int] = [1,4,7]
Upvotes: 1
Views: 619
Reputation: 593
Assuming you are ok with 1 = Sunday and 7 = Saturday, maybe something like this can be done:
First sort the array
weekdays = weekdays.sorted()
Then iterate through it
for i in weekdays {
let weekdayString = Calendar.current.weekdaySymbols[i - 1]
print(weekdayString)
}
Depending on your needs you may wish to use:
.weekdaySymbols
.shortWeekdaySymbols
.veryShortWeekdaySymbols
or
.standaloneWeekdaySymbols
.shortStandaloneWeekdaySymbols
.veryShortStandaloneWeekdaySymbols
Upvotes: 0