Solved

How To delete Event from Iphone Calendar Programmatically?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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.
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
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…

770 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