我正在尝试将新的保存到我创建EKEvent
的新本地日历中:
newCalendar.source = self.eventStore.sources.filter { (source: EKSource) -> Bool in source.sourceType.rawValue == EKSourceType.local.rawValue}.first!
do {
try self.eventStore.saveCalendar(newCalendar, commit: true)
} catch {
throw Error.calendarNotSaved
}
我返回日历标识符并创建一个新的 EKEvent 并保存:
newEvent.calendar = self.eventStore.calendar(withIdentifier: calendarIdentifier)!
do {
try eventStore.save(newEvent, span:.thisEvent, commit: true)
} catch {}
这失败并显示错误消息:
错误域 = EKErrorDomain 代码 = 54 “日历没有默认组织者。”
根据 Apple 的说法,您不能只使用现有的 EKSource 来创建新日历来创建新的 EKSource。. 就我而言,唯一的本地日历不包含任何EKOrganizer
信息,因此无法保存。有关如何解决此问题的任何建议?
更新:还应该补充一点,我试图通过 EKEvent.organizer 添加一个组织者,但这是一个只读属性,并从创建日历时使用的 EKSource 获取其信息。