我将经常性事件(EKEvent)写入日历。如何在特定日期获取和修改其中一个经常发生的事件?
这些事件是通过以下代码创建的:
+ (void) writeTestEvent{
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.calendar = [eventStore defaultCalendarForNewEvents];
event.title = @"Hello World!";
event.startDate = [NSDate date];
event.endDate = [NSDate date];
EKRecurrenceRule *recurrenceRule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily interval:1 end:nil];
[event addRecurrenceRule:recurrenceRule];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted) {
BOOL isSaved = [eventStore saveEvent:event span:EKSpanFutureEvents commit:YES error:&error];
NSLog(@"isSaved: (%d) with error: %@", isSaved, error);
} else {
NSLog(@"not granted with error: %@", error);
}
}];
}
使用-predicateForEventsWithStartDate:endDate:calendars:
仅获取日期范围内的事件,而不是特定事件。并且使用事件标识符仅获取一个事件,但没有特定日期。