defaultCalendarForNewEvents failed

On iOS6, Apple introduced a new privacy control that allows the user to control the accessibility of contacts and calenders for each app. So, on the code side, you need to add some way to request the permission. In iOS5 or before, we can always call

EKEventStore *eventStore = [[[EKEventStore alloc] init] autorelease];
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
    // iOS 6 and later
    [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (granted) {
            // code here for when the user allows your app to access the calendar
            [self performCalendarActivity:eventStore];
        } else {
            // code here for when the user does NOT allow your app to access the calendar
        }
    }];
} else {
    // code here for iOS < 6.0
    [self performCalendarActivity:eventStore];
}

Leave a Comment