36249

Delete all future recurring event from iPhone calendar

Question:

Can any one having idea how to delete recurring event from iPhone calendar?

I am using this code for store event which is repeat every week.

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]; }

Now I want to delete all future events from the iPhone calendar.

Thanks!

Answer1:

Got Solution my self.

For delete all future events I am using this code

EKEventStore* store = [[EKEventStore alloc] init] ; EKEvent* eventToRemove = [store eventWithIdentifier:strIdentifier]; if (eventToRemove != nil) { NSError* error = nil; [store removeEvent:eventToRemove span:EKSpanFutureEvents error:&error]; }

For Delete current day entry we have to use "EKSpanThisEvent" and for delete future events we have to use "EKSpanFutureEvents"

Recommend

  • Choosing Calendar to add an iOS event
  • Convert NSDates from one calendar to another
  • WPF Interaction triggers in a Style to invoke commands on View Model [duplicate]
  • Populating a UITableView with plist dictonary
  • How to add to this update SQL statement and make a drop down list too for it
  • Play Alarm Sound when app is not running IOS
  • Getting NSDate from NSString
  • Blink image with JQuery
  • Customizing the WP Schedule event
  • http request every x seconds in angular
  • Non-overlapped transparent control
  • Resolving DateTime Difference in PHP
  • Divide two counts from one select
  • Toggle setLineDash()
  • Convert a plain string[] into a Observable and concat it to another Observable using RxJS 5
  • MySQL: select last full 5 minute interval
  • table design + SQL question
  • Context is null in SignalR hub
  • Is it possible to set an Android Notification or a later date and time that will fire when the app i
  • View Azure WebJob Schedule in Portal?
  • How to Get date from week number and year
  • Recursive method 10x slower than interative [closed]
  • Resample in a rolling window using pandas
  • How to implement a filter from another stream using RxJava
  • Behaviour of System.Timer when Interval property changed
  • function cannot execute on segment because it accesses relation
  • How can I get new CSRF token in LARAVEL by using ajax
  • iOS Date formatting
  • MySql - get days remaining
  • data.table replicate rows after join?
  • iOS 6 dateFromString returns wrong date
  • Runtime.exec() gives Error: Could not find or load main class
  • wxPython: displaying multiple widgets in same frame
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Display issues when we change from one jquery mobile page to another in firefox
  • To display the title for the current loaction in map in iphone
  • Compare two NSDates in iPhone
  • trying to dynamically update Highchart column chart but series undefined
  • Change div Background jquery