谁知道如何从 iPhone 日历中删除重复发生的事件?
我将此代码用于每周重复的商店事件。
EKEventStore *eventSotre = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventSotre];
EKRecurrenceRule *recurrenceRule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyWeekly interval:1 end:nil];
[event addRecurrenceRule:recurrenceRule];
[event setCalendar:[eventSotre defaultCalendarForNewEvents]];
event.title= @"EventTitle";
NSDate *duedate = [NSDate date];
event.startDate =duedate;
event.endDate= duedate;
NSArray *arrAlarm = [NSArray arrayWithObject:[EKAlarm alarmWithAbsoluteDate:duedate]];
event.alarms= arrAlarm;
NSError *err;
BOOL isSuceess=[eventSotre saveEvent:event span:EKSpanThisEvent error:&err];
strIdentifier = [[NSString alloc] initWithFormat:@"%@", event.eventIdentifier];;
if(isSuceess){
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Event" message:@"Event added in calendar" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertview show];
}
else{
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Event" message:[err description] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertview show];
}
现在我想从 iPhone 日历中删除所有 future 的事件。
谢谢!
最佳答案
我自己找到了解决方案。
为了删除所有 future 的事件,我正在使用此代码
EKEventStore* store = [[EKEventStore alloc] init] ;
EKEvent* eventToRemove = [store eventWithIdentifier:strIdentifier];
if (eventToRemove != nil) {
NSError* error = nil;
[store removeEvent:eventToRemove span:EKSpanFutureEvents error:&error];
}
要删除当天条目,我们必须使用“EKSpanThisEvent”,要删除 future 事件,我们必须使用“EKSpanFutureEvents”
关于ios - 从 iPhone 日历中删除所有 future 重复发生的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25480045/