I can add a new calendar to the user's calendars like this, using the saveCalendar(_:commit:)
method:
let ekStore = EKEventStore()
func saveCalendar(calendar: EKCalendar) throws {
try ekStore.saveCalendar(calendar, commit: true)
}
let newList = EKCalendar(for: .reminder, eventStore: store.ekStore)
newList.source = store.ekStore.defaultCalendarForNewReminders()?.source
newList.title = newListName
newList.cgColor = listColor
do {
try saveCalendar(calendar: newList)
} catch {
print("Error adding list: \(error.localizedDescription)")
}
And I store the calendar object.
When the user finishes editing a calendar (reminders list) in my app, I try to save it like this, using the stored calendar as a starting point:
let updatedList = existingCalendar
updatedList.title = newListName
updatedList.cgColor = listColor
do {
try saveCalendar(calendar: updatedList)
} catch {
print("Error saving list: \(error.localizedDescription)")
}
But the calendar doesn't save and I get this error: That account does not support reminders.
.
I have also tried explicitly setting the calendar's source:
updatedList.source = store.ekStore.defaultCalendarForNewReminders()?.source
but then I get this error: That calendar may not be moved to another account.
.
My Question: How do I update calendars (reminder lists) from my app?