Reputation: 16664
How to prefill title and location for created event in EKEventEditViewController?
Should I create EKEvent programmatically first, and then edit it? In this case how to delete it if user touched cancel?
Upvotes: 0
Views: 936
Reputation: 1188
Create the event first, then edit it.
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.startDate = lastSelectedDate; // your selected start date
event.endDate = [lastSelectedDate dateByAddingTimeInterval:60*60*2]; // your selected end date
// Creating event controller
EKEventEditViewController *eventViewController = [[EKEventEditViewController alloc] init];
eventViewController.editViewDelegate = self;
eventViewController.eventStore = eventStore;
// Set event
eventViewController.event = event;
[self presentViewController:eventViewController animated:YES completion:nil];
Upvotes: 0
Reputation: 3679
When you have set the eventStore
property into the EKEventEditViewController
, it will have created its own event. You can edit that before you display the EKEventEditViewController
.
Upvotes: 1
Reputation: 16664
The answer is: create EKEvent programmatically first, and then edit it.
It works.
Upvotes: 0