Set the delegate
method of your EKEventEditViewController
to self
and then, add the following method to catch it.
#pragma mark -
#pragma mark EKEventEditViewDelegate
// Overriding EKEventEditViewDelegate method to update event store according to user actions.
- (void)eventEditViewController:(EKEventEditViewController *)controller
didCompleteWithAction:(EKEventEditViewAction)action {
NSError *error = nil;
//EKEvent *thisEvent = controller.event;
switch (action) {
case EKEventEditViewActionCanceled:
// Edit action canceled, do nothing.
break;
case EKEventEditViewActionSaved:
// When user hit "Done" button, save the newly created event to the event store,
// and reload table view.
// If the new event is being added to the default calendar, then update its
// eventsList.
[controller.eventStore saveEvent:controller.event span:EKSpanThisEvent error:&error];
break;
case EKEventEditViewActionDeleted:
// When deleting an event, remove the event from the event store,
// and reload table view.
// If deleting an event from the currenly default calendar, then update its
// eventsList.
break;
default:
break;
}
// Dismiss the modal view controller
[controller dismissViewControllerAnimated:YES completion:nil];
}
Also, make sure your your interface in header file in conforming to the EKEventEditViewDelegate like below:
.h file
@interface EventViewController : UIViewController <EKEventEditViewDelegate> {}
Here is how to check to see if you were granted permission to add/modify events:
EKEventStore *store = [[EKEventStore alloc] init];
if([store respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
//Access not granted-------------
if(!granted){
}
//Access granted
}else{
}
}];
}