i am using a simple code to store calendar events programmatically i had search for many solutions on stack but all are mentioned in SWIFT stack-1 stack -2 and i am using Object-C here is the code that i use:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"MM/dd/yyyy"];
EKEventStore *store = [EKEventStore new];
[store requestAccessToEntityType:EKEntityMaskEvent completion:^(BOOL granted, NSError *error) {
NSLog(@"%@",error);
if (!granted) { return; }
EKEvent *event = [EKEvent eventWithEventStore:store];
event.title = @"Restaurant Table";
event.startDate = [NSDate date];
// event.endDate = [event.startDate dateByAddingTimeInterval:60*60]; //set 1 hour meeting
event.calendar = [store defaultCalendarForNewEvents];
NSError *err = nil;
[store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
// self.savedEventId = event.eventIdentifier; //save the event id if you want to access this later
}];
Thanks in advance and for source code here its Programmatically add custom event in the iPhone Calendar