I am trying to save a new EKEvent
to a new local calendar I create using:
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
}
I return the calendar identifier and create a new EKEvent and save with:
newEvent.calendar = self.eventStore.calendar(withIdentifier: calendarIdentifier)!
do {
try eventStore.save(newEvent, span:.thisEvent, commit: true)
} catch {}
This fails with the error message:
Error Domain=EKErrorDomain Code=54 "Calendar does not have a default organizer."
According to Apple, you can not create a new EKSource just use an existing one to create a new calendar.. In my case, the only local calendar does not contain any EKOrganizer
information and is, therefore, unable to save. Any suggestions for how to move around this problem?
Update: Should also add that I have tried to add an organizer through EKEvent.organizer but that is a read-only property and takes its information from the EKSource you use when creating the calendar.