Solved

How To delete Event from Iphone Calendar Programmatically?

Posted on 2010-09-07
1
6,179 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I'm Dumb-phoned(ed) Last week, I noticed this message when adding events to my Google Calendar: On June 27th (2015), Google is removing SMS as a notification option for Google Calendar events.  Their assumption is that enough people have smart p…
iCloud Drive was introduced after iOS 8 was launched last year. This drive is Apple’s online storage device that lets users sync their files and access them from all their Apple devices.   There is a lot of data that is not automatically backed up…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now