Solved

How To delete Event from Iphone Calendar Programmatically?

Posted on 2010-09-07
1
6,297 Views
Last Modified: 2012-06-21
How To delete Event from Iphone Calendar Programmatically?

I am trying to delete Event From Iphone Calendar tell me how to delete Event From Iphone Calendar Programmatically


Here Is the way  to add event in iphone calendar

	////// Saving Event In Calendar 
	EKEventStore *eventStore = [[EKEventStore alloc] init];
	EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = appDelegate.title1;
	event.startDate = appDelegate.selecteddatafromcalendar;
	event.endDate   = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];
    [event setCalendar:[eventStore defaultCalendarForNewEvents]];
    NSError *err;
    [eventStore saveEvent:event span:EKSpanThisEvent error:&err];
	////// Saving Event In Calendar 

Open in new window



I am trying to delete Event On user Request


and also tell me how to get event Id
// Deleting Event
       EKEventStore *eventStore = [[EKEventStore alloc] init];
	NSError *err;
	[eventStore removeEvent:event span:EKSpanThisEvent error:&err];

Open in new window




Below is the function i m calling To remove Event From Event Array
- (BOOL)removeEvent:(EKEvent *)event span:(EKSpan)span error:(NSError **)error{
	VoiceRecorderAppDelegate *appDelegate = (VoiceRecorderAppDelegate *)[[UIApplication sharedApplication] delegate];
	[items removeObjectAtIndex:appDelegate.objectindexpath];
}

Open in new window



My job is to remove Selected from Item Array


Kindly Check My code and Give Response As soon As possible
0
Comment
Question by:IamnotanExpert007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
IamnotanExpert007 earned 0 total points
ID: 33711264
well i found the answer
use there line when you are saving events
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
   NSString* str = [[NSString alloc] initWithFormat:@"%@", event.eventIdentifier];
[arrayofCalIDs addObject:str];



in order to delete event you there lines
event delete with the help of eventwithidentifier this is use to find event id from iphone calendar


EKEventStore* store = [[[EKEventStore alloc] init] autorelease];
   EKEvent* event2 = [store eventWithIdentifier:[arrayofCalIDs objectAtIndex:i]];
if (event2 != nil) {  
  NSError* error = nil;
  [store removeEvent:event2 span:EKSpanThisEvent error:&error];
}
[myPath release];


Problem solveD
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn new improvements released by Google for Google Calendar. Noted in this article are simple tips and tricks that can make your everyday use of Google Calendar better.
There is a lot to be said for protecting yourself and your accounts with 2 factor authentication.  I found to my own chagrin, that there is a big downside as well.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question