简体   繁体   English

iOS EventKit其他谓词

[英]iOS EventKit Additional Predicates

I'm building an app that has some iOS calendar functionality built into it. 我正在构建一个内置一些iOS日历功能的应用。 The user can create events and send them to their iCal, but I only want events created in my app to show on the calendar in the app. 用户可以创建事件并将其发送到他们的iCal,但我只希望在我的应用程序中创建的事件显示在应用程序的日历中。

I know I can use predicates like below: 我知道我可以使用如下谓词:

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

But I also have an array of eventIdentifiers that I would like to add as a condition. 但我也有一个eventIdentifiers数组,我想添加为条件。 So, I want events from the eventstore as above, but only if the event matches an event identifier in my array. 因此,我希望从上述事件存储中获取事件,但前提是该事件与我数组中的事件标识符匹配。 Is that possible? 那可能吗?

Instead of actually fetching all the events into an array with eventsMatchingPredicate , call enumerateEventsMatchingPredicate . 调用enumerateEventsMatchingPredicate而不是将所有事件实际提取到带有eventsMatchingPredicate的数组中。 This allows you to filter out further the results, keeping only the ones you like. 这使您可以进一步过滤出结果,仅保留所需的结果。 Remember to get onto a background thread first! 请记住先进入后台线程!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM