EKRecurrenceRule不起作用

时间:2012-04-21 08:15:43

标签: ios calendar icalendar eventkit ekeventkit

我已经按照了一些教程并查看了文档,并认为我有正确的代码,但它仍然不想再发生。任何想法将非常感激。我的代码如下。感谢。

 EKRecurrenceEnd *endRecurrence = [EKRecurrenceEnd recurrenceEndWithOccurrenceCount:14];

    EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyWeekly interval:1 end:endRecurrence];

    NSMutableArray *rules = [[NSMutableArray alloc] init];

    [rules arrayByAddingObject:rule];

    event.recurrenceRules = rules; 

1 个答案:

答案 0 :(得分:4)

我相信你这样做的方式是这样的:(我已经添加了一个案例,如果你想要摆脱已经存在的任何规则)

NSArray* rulesArray = [event recurrenceRules];

for (EKRecurrenceRule* rule in rulesArray) [event removeRecurrenceRule:rule];

EKRecurrenceEnd *endRecurrence = [EKRecurrenceEnd recurrenceEndWithOccurrenceCount:14];

    EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyWeekly interval:1 end:endRecurrence];

    [event addRecurrenceRule:rule]; 

    [rule release];

然后只需添加另一个