I tried to create a calendar from my app. It does not work on an iPhone 6, the app crashed.
Here is my code:
do {
let calender = EKCalendar(for: .event, eventStore: eventStore)
calender.title = "MyApp"
calender.source = eventStore.defaultCalendarForNewEvents.source
try eventStore.saveCalendar(calender, commit: true)
userDefaults.set(calender.calendarIdentifier, forKey: calendarIdentifierKey)
userDefaults.synchronize()
} catch {
print("Error occurred while creating calendar ")
}
Update
- In the phone the default calendar is set as xxx.gmail.com
And the following error is thrown
Error occurred while creating calendar