Solved

How To delete Event from Iphone Calendar Programmatically?

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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.
The case of the missing phone talks about the way a small electronic gadget (the mobile phone) has penetrated into our lives and has made us addicted to it.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now