Example
Creating the event object
Swift
var event = EKEvent(eventStore: eventStore)
Objective-C
EKEvent *event = [EKEvent initWithEventStore:eventStore];
Setting related calendar, title and dates
Swift
event.calendar = calendar
event.title = "Event Title"
event.startDate = startDate //assuming startDate is a valid NSDate object
event.endDate = endDate //assuming endDate is a valid NSDate object
Adding event to calendar
Swift
try {
do eventStore.saveEvent(event, span: EKSpan.ThisEvent)
} catch let error as NSError {
//error
}
Objective-C
NSError *error;
BOOL *result = [eventStore saveEvent:event span:EKSpanThisEvent error:&error];
if (result == NO){
//error
}