-1

I have following example where I get:

Error getting all calendars: Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"

This is a place:

  _estore = EKEventStore()
  _estore.reset()

_estore.requestAccessToEntityType(EKEntityTypeEvent, completion: {(granted:Bool!, error:NSError!) in

   if  granted == true {

      println("#########   allowed calendar accounts   #########")

      var calendars = self._estore.calendarsForEntityType(EKEntityTypeEvent) // <-- Exception
   }

})//block

I get proper popup Allow/No - I click on Allow and with debug I enter under granted

But get Exception.

from THIS answer by @yunas I tried to wrap my code with:

if _estore.respondsToSelector(Selector("completion:")){ /* ... */ }

But in this case I never enter to that if

Whats is wrong with code?

Please help,

Community
  • 1
  • 1
snaggs
  • 5,543
  • 17
  • 64
  • 127

1 Answers1

0
_estore.requestAccessToEntityType(EKEntityTypeEvent, completion: {(granted:Bool!, error:NSError!) in

   if  granted == true {
    let calendars : [EKCalendar] = _estore.calendarsForEntityType(EKEntityTypeEvent) as [EKCalendar]
   }

Try this.

Mrunal
  • 13,982
  • 6
  • 52
  • 96