EKCADErrorDomain使用calendarWithIdentifier

在我的iOS应用程序中,我用以下方法访问日历:

EKCalendar* cal = [eventStore calendarWithIdentifier:[calendarIDs objectAtIndex:i]]; 

通过以下方式向用户询问权限:

 eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted,NSError* error){} 

现在这在iOS 7上正常工作,但在iOS 8上,我每次调用方法calendarWithIdentfier时都会收到以下错误:

 Error getting shared calendar invitations for entity types 3 from daemon: Error Domain=EKCADErrorDomain Code=1013 "The operation couldn't be completed. (EKCADErrorDomain error 1013.)" 

我可以写\读没有问题的日历,但我不明白为什么会引发这个exception。 我已经尝试了一些在这里提出的方法,但没有一个似乎在这种情况下工作。

我也被困在同样愚蠢的事情上。

我只是打了一个日历数组,并根据标识符进行匹配。 这不是优雅的,但它的工作原理和普通用户可能有不到10个日历,所以…哦..

这是我在swift中的解决方法

 func createEvent(){ var event = EKEvent(eventStore: self.eventStore) var calendar : EKCalendar! let calendars : [EKCalendar] = self.eventStore.calendarsForEntityType(EKEntityTypeEvent) as [EKCalendar] for aCal in calendars { if(aCal.calendarIdentifier == self.calendarIdentifier) { calendar = aCal break } } ...continue to do stuff to events.... }