问题
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:
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.
来源:https://stackoverflow.com/questions/20398697/past-events-in-ekcalendar