Sauron Sauron - 1 year ago 394
iOS Question

How to setup EKRecurrenceRule rule for repeating once a week

How can I best create a

in swift to allow for scheduling an event once a week, possibly several days a week.

For example, a new event is to occur every Friday and Saturday weekly.

var dayOfWeek = [EKWeekday.Friday, EKWeekday.Saturday]

EKRecurrenceRule(recurrenceWithFrequency: EKRecurrenceFrequency.Weekly, interval: 1, daysOfTheWeek: dayOfWeek)

At present, above does not work

How can this be formulated?

(The examples and tutorials for swift are sparse)

Answer Source

This should do it:

let friday = EKRecurrenceDayOfWeek(.Friday)
let saturday = EKRecurrenceDayOfWeek(.Saturday)

EKRecurrenceRule(recurrenceWithFrequency: .Weekly, interval: 1, daysOfTheWeek: [friday, saturday], daysOfTheMonth: nil, monthsOfTheYear: nil, weeksOfTheYear: nil, daysOfTheYear: nil, setPositions: nil, end: nil)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download