iOS EventKit附加谓词

时间:2015-10-17 23:03:55

标签: ios objective-c eventkit

我正在构建一个内置了iOS日历功能的应用。用户可以创建事件并将其发送到他们的iCal,但我只希望在我的应用程序中创建的事件显示在应用程序的日历上。

我知道我可以使用如下的谓词:

NSPredicate *predicate = [_eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:preferredAppleCalendars];
NSArray *appleEventsArray = [_eventStore eventsMatchingPredicate:predicate];

但是我还有一个eventIdentifiers数组,我想添加它作为一个条件。所以,我想要如上所述来自eventstore的事件,但前提是事件匹配我的数组中的事件标识符。这可能吗?

1 个答案:

答案 0 :(得分:2)

不是实际使用eventsMatchingPredicate将所有事件提取到数组中,而是调用enumerateEventsMatchingPredicate。这允许您进一步过滤结果,只保留您喜欢的结果。记得首先进入后台线程!