Calendar List is empty after authorization

I'm having issues with EventKit.

  • Before requesting any data from EventKit, I request auth access to reminders and calendar.

  • In the App Sandbox configuration, I've checked off Reminders.

  • After requesting access, I call reset() on the EKEventStore I created.

  • The first time after access is approved, a call to "store.calendars(for: .event)" returns zero results (calls to "store.predicateForEvents" WILL return results).

  • If I force quit the app and launch it again, I get results for "store.calendars(for: .event)"

What am I missing here?

What's weird is, before all this started happening, everything was working correctly without the store.reset() call - even the calendars were getting returned.

However, I accidentally deleted my App's Target and had to recreate it. Since recreating the build target, I was NOT getting results for "store.predicateForEvents" until I called "store.reset()" after authorization was granted. But I still can't get the calendar list after first launch.


I don't know if it's a bug or not but store.reset() does not seem to actually reset the store like the comments suggests,

It essentially is as if you released the store and then created a new one. It brings it back to its initial state.

If we actually do create a new store, the issue seems to be resolved. So the access handler should look something like this:
Code Block
store.requestAccess(to: .event) { (granted, error) in
if granted {
self.store = EKEventStore()
...
}


I found the answer on this post. Stack Overflow.
Calendar List is empty after authorization
 
 
Q