Search code examples
ekeventkit

Get events from all the EKCalendar


I want to get events from all the calendars (home,work,calendar and birthday). I am getting events from the defaultcalendar, but cannot fetch events from Birthday calendar. Any help will be great.


Solution

  • This answer might help you:

    NSDate* endDate =  [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]];
    NSArray *calendarArray = [NSArray arrayWithObject:cal];
    NSPredicate *fetchCalendarEvents = [eventStore predicateForEventsWithStartDate:[NSDate date] endDate:endDate calendars:calendarArray];
    NSArray *eventList = [eventStore eventsMatchingPredicate:fetchCalendarEvents];
    
    for(int i=0; i < eventList.count; i++){
    
        NSLog(@"Event Title:%@", [[eventList objectAtIndex:i] title]);
    
    }