错误发生在页面底部。我目前正在运行Xcode 7.0,在尝试保存事件时无法编译代码。我用相同的问题查看了其他人的帖子,但它并不适用于我的代码。我很感激帮助!
func insertEvent(store: EKEventStore) {
// 1
let calendars = store.calendarsForEntityType(EKEntityType.Event)
as! [EKCalendar]
for calendar in calendars {
// 2
if calendar.title == "ioscreator" {
// 3
let startDate = NSDate()
// 2 hours
let endDate = startDate.dateByAddingTimeInterval(2 * 60 * 60)
// 4
// Create Event
var event = EKEvent(eventStore: store)
event.calendar = calendar
event.title = "New Meeting"
event.startDate = startDate
event.endDate = endDate
// 5
// Save Event in Calendar
var error: NSError?
let result = store.saveEvent(event, span: .ThisEvent, error: &error) // Error is here
if result == false {
if let theError = error {
print("An error occured \(theError)")
}
}
}
}
}