如何设置EKRecurrenceRule规则,每周重复一次

时间:2016-05-29 21:22:13

标签: ios swift eventkit

如何在swift中最好地创建EKRecurrenceRule以允许每周安排一次事件,可能每周安排一次。

例如,每周五和周六每周都会举办一次新活动。

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

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

目前,上述不起作用

如何制定这个?

(swift的示例和教程很稀疏)

1 个答案:

答案 0 :(得分:5)

这应该这样做:

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)