我創建iOS應用程序,它從服務器獲取日期並將它們添加活動的日曆刪除所有事件從日曆
- (void)addReminderWithTitle:(NSString *)title date:(NSString *)date {
NSString *dateString = date;
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSDate *dateFromString = [dateFormatter dateFromString:dateString];
[dateFromString dateByAddingTimeInterval:-60*30];
EKEventStore *eventStore = [[EKEventStore alloc] init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted) {
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = title;
event.startDate = dateFromString;
//[NSDate date]; //today
event.endDate = [event.startDate dateByAddingTimeInterval:60*60]; //set 1 hour meeting
event.calendar = [eventStore defaultCalendarForNewEvents];
NSError *err = nil;
[eventStore saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
}}];
}
,我需要一個功能,這將刪除用戶在特定操作中的所有事件。 有幫助嗎?
可能重複:http://stackoverflow.com/questions/28321921/how-to-delete-all-the-事件 - 我的應用程序日曆 - 當應用程序被刪除從設備?rq = 1 –