添加活动

创建事件对象

迅速

var event = EKEvent(eventStore: eventStore)

Objective-C

EKEvent *event = [EKEvent initWithEventStore:eventStore];

设置相关的日历,标题和日期

迅速

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

将事件添加到日历

迅速

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
}