I am developing an iphone app using Monotouch. I am able to add events to the DefaultCalendarForNewEvents calendar (the same calendar I’m using to find and delete them) without a problem. However, every time I call a method in the app to remove an event from the calendar, every instance of the event still shows up in the calendar application even if the calendar application is shut down and restarted, or ensured that it was not running while my app was manipulating the calendar. I’m getting breakpoints on the RemoveEvents line, and it is returning true. This is my function:
public static void descheduleReminderEvent(string presc_id_for_del) {
EKEventStore store = new EKEventStore();
EKCalendar calendar = store.DefaultCalendarForNewEvents;
if (calendar != null) {
NSDictionary readonlyDic = dStor.DictionaryForKey("savedCalReminders");
if(readonlyDic != null) {
NSMutableDictionary savedCalReminders = NSMutableDictionary.FromDictionary(readonlyDic);
foreach(NSString prescId in savedCalReminders.Keys) {
if(string.Compare(prescId, presc_id_for_del) == 0) {
EKEvent currentEvent = store.EventFromIdentifier(savedCalReminders.ObjectForKey(prescId).ToString());
if(currentEvent != null) {
savedCalReminders.Remove(prescId);
dStor.SetValueForKey(savedCalReminders, new NSString("savedCalReminders"));
store.RemoveEvents(currentEvent, EKSpan.FutureEvents, new IntPtr());
}
break;
}
}
}
}
}
Can someone tell me what I’m missing?
Turns out my problem was elsewhere and monodevelop just wasn’t throwing the errors. The code above will in fact remove events if anyone cares to use it.