Past events in EKCalendar

橙三吉。 提交于 2019-12-13 17:28:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!