本文介绍了EKCalendar中的过往活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从确定的EKCalendar
中获取所有事件,但是如果我用predicateForEventsWithStartDate:endDate:calendars:
生成的谓词和过去的'startDate
'调用eventsMatching Predicate:
,则会得到一个空对象.是个虫子吗?还是没有办法检索过去的事件?
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?
编辑(NSData十进制):
EDIT (NSData decalarations):
[[self eventStore] predicateForEventsWithStartDate:[NSDate distantPast] endDate:[NSDate distantFuture] calendars:syncedCalendars]
推荐答案
尝试将您的代码更改为:
Try change your code to to:
NSDate* futureDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]];
[[self eventStore] predicateForEventsWithStartDate:[NSDate date] endDate: futureDate calendars:syncedCalendars]
还要确保您的syncedCalendars是NSArray类型.
Also make sure that your syncedCalendars is NSArray type.
这篇关于EKCalendar中的过往活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!