I am working on EKEvent in iOS5. I am able to add, delete, list events but now the problem is when I try to edit an existing event, the "Done" button creates problems. It is not going inside eventEditViewController: method. What might be the problem? Any help will be appreciated. Cancel and Delete button are working. When I edit the event and click "Done", the console shows
Calendar: unable to save: (null)
.
Here is the code I tried..
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
EKEventEditViewController* eventViewController = [[EKEventEditViewController alloc] init];
event = [self.events objectAtIndex:indexPath.row];
eventViewController.event = event;
eventViewController.editViewDelegate = self;
[self presentModalViewController: eventViewController animated:YES];
[eventViewController release];
}
-(void)eventEditViewController:(EKEventEditViewController *)controller
didCompleteWithAction:(EKEventEditViewAction)action {
EKEvent *thisEvent = controller.event;
NSError *error;
if ([controller.event.endDate isEqualToDate:controller.event.startDate]) {
controller.event.endDate = [controller.event.startDate dateByAddingTimeInterval:1.0]; // add one second
}
switch (action) {
case EKEventEditViewActionCancelled:
// User tapped "cancel"
NSLog(@"Canceled");
break;
case EKEventEditViewActionSaved:
NSLog(@"Saved");
[controller.eventStore saveEvent:controller.event span: EKSpanFutureEvents error:&error];
break;
case EKEventEditViewActionDeleted:
// User tapped "delete"
NSLog(@"Deleted");
// delete the event from event list
[self.events removeObject:thisEvent];
// delete the event from event store
[self.eventStore removeEvent:thisEvent span:EKSpanThisEvent error:nil];
// reload the tableView
[self.tableOutlet reloadData];
break;
default:
NSLog(@"Default");
break;
}
[self dismissModalViewControllerAnimated:YES];
}
According to the docs,
So,