Past events in EKCalendar

262 views Asked by At

I'm trying to get all the events from a determined EKCalendar, but if I call eventsMatching Predicate: with a predicate generated with predicateForEventsWithStartDate:endDate:calendars: and a past 'startDate' I get a null object. It's a bug? Or there is no way I can retrive the past events?

EDIT (NSData decalarations):

[[self eventStore] predicateForEventsWithStartDate:[NSDate distantPast] endDate:[NSDate distantFuture] calendars:syncedCalendars]
1

There are 1 answers

3
Greg On

Try change your code to to:

    NSDate* futureDate =  [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]];
    [[self eventStore] predicateForEventsWithStartDate:[NSDate date] endDate: futureDate calendars:syncedCalendars]

Also make sure that your syncedCalendars is NSArray type.