1

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]
Nicolò Ciraci
  • 678
  • 5
  • 23

1 Answers1

0

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.

Greg
  • 25,317
  • 6
  • 53
  • 62
  • It's not this problem, I want retrive the PAST events. Passing [NSDate date] will not retrive past events. – Nicolò Ciraci Dec 05 '13 at 11:42
  • I think there is some issue with [NSDate distantPast] call. I couldn't make it worked either. Maybe try subtract time interval from [NSDate date] to get date in the past. – Greg Dec 05 '13 at 12:07
  • Yep, what I've done :) But I can't further that 1/1/2010, even with 29/12/2009 I get a null array. – Nicolò Ciraci Dec 05 '13 at 12:12