In my app I am saving events to calendar..
But If the event is from 1 Feb, 2015 to 20 Feb, 2015.
How can I delete the Events from 1 Feb, 2015 to 15 Feb, 2015 as those are completed events.
I googled and found the answer using Settings option of iPhone
https://apple.stackexchange.com/questions/103570/auto-delete-previous-old-events-from-ios-7-calendar
I use below code to delete all events of my calendar
NSDate *startDate = [NSDate date];
NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]];
NSArray *calendarArray = [NSArray arrayWithObject:self.defaultCalendar];
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArray];
NSArray *events = [self.eventStore eventsMatchingPredicate:predicate];
for (EKEvent *event in events)
{
NSError* err = nil;
[self.eventStore removeEvent:event span:EKSpanFutureEvents commit:YES error:&err];
}
But is any way of deleting old Events that are completed.Else delete Older than Feb, 2015 Events programmatically.
Note: I am using Recurrence Events that take 14 days if End date is not set..
Any ideas & suggestions how to fix it..
Thanks in Advance..!