0

I've recently found out, that I do not receive any EKCalendar objects from EKEventStore in iOS7. In iOS 6.x.x there are no problems with same code snippet. When I'm trying to access defaultCalendarForNewEvents - I do receive a single EKCalendar object (as expected).

I do request access to entity type EKEntityTypeEvent.

The snippet:

__block NSMutableArray *calendarsArray = nil;

if ([self.eventsStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
    [self.eventsStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (granted) {
            EKAuthorizationStatus status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];

            if (status == EKAuthorizationStatusAuthorized) {
                calendarsArray = [[NSMutableArray alloc] initWithArray:[self.eventsStore calendarsForEntityType:EKEntityMaskEvent]];
            }
        } else {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"You haven't granted access to calendars. Expected things are not going to happen." delegate:nil cancelButtonTitle:@"I understand" otherButtonTitles:nil];
            [alert show];
        }
    }];
} else {
    calendarsArray = [NSMutableArray arrayWithArray:[self.eventsStore calendarsForEntityType:EKEntityTypeEvent]];
}

I do receive 0 objects into calendarsArray. I've also tried to get it by "running through" all EKSources that are of type Local or CalDAV ([source calendarsForEntityType:] - got the same empty (0 object containing) set).

By the way - access to calendars IS granted.

Any suggestions?

Robert
  • 11
  • 1
  • 4
  • This occurs on iPhone 4 and iPhone 5 (both run iOS 7.0.3). Furthermore, on both devices there are additionally connected two calendars via CalDAV. – Robert Oct 31 '13 at 11:36
  • Additionally, running other tests (writing addtional app, etc.) I have noticed that it is also not possible to create a calendar in Local storage. – Robert Nov 06 '13 at 16:33

1 Answers1

1

After a brief investigation I have found out, that the problem was not in the code. It appears that the problem is in iOS 7.0.3 itself.

After deleting all the sync'ed calendars from the iDevice and adding it back all of the calendars were displayed both within the native Calendar application, and the one I made. After taking this action my code was able to retrieve the calendars from EventStore not depending on the method I would access calendars (via EKSources or EKEventStore itself).

Robert
  • 11
  • 1
  • 4