I am facing an issue while creating a calendar, i've signed out from iCloud to remove all other merged calendars. Now, there is only Gmail and yahoo calendars left and gmail is my default calendar. I want to create my own calendar and mark it as default but couldn't.
I used this eventStore.defaultCalendarForNewEvents.source
to assign source to my newly created calendar and got some error like this
"This source doesn't allow to edit content etc."
Although this code returns true print(eventStore.defaultCalendarForNewEvents.allowsContentModifications)
Is there a way of creating your own, because we can see other apps i.e Google, Yahoo etc have created their own. Here's the code for creating new calendar
let newCalendar = EKCalendar(for: .event, eventStore: eventStore)
newCalendar.title = "Test Calendar"
do {
newCalendar.source = eventStore.defaultCalendarForNewEvents.source
try eventStore.saveCalendar(newCalendar, commit: true)
} catch {
let alert = UIAlertController(title: "Calendar could not save", message: error.localizedDescription, preferredStyle: .alert)
let OKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(OKAction)
self.present(alert, animated: true, completion: nil)
}
Thanks