Add Eventkit framework to your project
//Code Snippet:
EKEventStore *store;
store=[[EKEventStore alloc] init];
//for iOS 7.0 and above we need to have the permission of user for using eventkit that is the calendar
//ask for permission:
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error){
// handle access here
if(granted)
{
//configure event:
EKEvent *addNewEvent=[EKEvent eventWithEventStore:store];
addNewEvent.startDate=fromDate;
addNewEvent.endDate=toDate;
EKCalendar *defaultCalendar=[store defaultCalendarForNewEvents];
addNewEvent.calendar=defaultCalendar;
EKRecurrenceRule *recRule=[[EKRecurrenceRule alloc] init];
addNewEvent.recurrenceRules=[NSArray arrayWithObject:recRule];
BOOL status= [store saveEvent:addNewEvent span:EKSpanThisEvent commit:YES error:&error];
if(status)
{
NSLog(@”Successfully saved”);
}
else
{
//error in saving
// NSLog(@”error in saving: %@”,error);
}
}
}
];