You can access a user calendar to insert new event, or to edit or delete.
Some code snippets:
Import EventKit
1
#import <EventKit/EventKit.h>
Add Event
123456789101112
EKEventStore*store=[[EKEventStorealloc]init];[storerequestAccessToEntityType:EKEntityTypeEventcompletion:^(BOOLgranted,NSError*error){if(!granted)return;EKEvent*event=[EKEventeventWithEventStore:store];event.title=@"Event Title";event.startDate=[NSDatedate];// todayevent.endDate=[event.startDatedateByAddingTimeInterval:60*60];// Duration 1 hr[eventsetCalendar:[storedefaultCalendarForNewEvents]];NSError*err=nil;[storesaveEvent:eventspan:EKSpanThisEventcommit:YESerror:&err];NSString*savedEventId=event.eventIdentifier;// Store this so you can access this event later}];
Edit Event
12345678910111213
EKEventStore*store=[[EKEventStorealloc]init];[storerequestAccessToEntityType:EKEntityTypeEventcompletion:^(BOOLgranted,NSError*error){if(!granted)return;EKEvent*event=[storeeventWithIdentifier:savedEventId];// Uncomment below if you want to create a new event if savedEventId no longer exists// if (event == nil)// event = [EKEvent eventWithEventStore:store];if(event){NSError*err=nil;event.title=@"New event title";[storesaveEvent:eventspan:EKSpanThisEventcommit:YESerror:&err];}}];