ios - EKEventStore编程Xcode iOS异步搜索

标签 ios xcode ekevent ekeventstore

文档指出:

  • (void)enumerateEventsMatchingPredicate:(NSPredicate *)predicate usingBlock:(EKEventSearchCallback)block

This method is synchronous. For asynchronous behavior, run the method on another thread with dispatch_async or NSOperation.

如何使这个异步,句子并没有真正演示它。谁能解释一下吗?

谢谢

D:-)

最佳答案

要么全部发送:

#include <stdio.h>

int main(int argc, char *argv[]) {
    ...
    dispatch_async(dispatch_get_global_queue(0,0), ^{
        [store enumerateEventsMatchingPredicate:p usingBlock:^(..) {
            //DO IT
        }];
    });
    ...
}

或回调

#include <stdio.h>

int main(int argc, char *argv[]) {
    ...
    [store enumerateEventsMatchingPredicate:p usingBlock:^(..) {
        dispatch_async(dispatch_get_global_queue(0,0), ^{
        //DO IT
        });
    }];

    ...
}

关于ios - EKEventStore编程Xcode iOS异步搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27024816/

相关文章:

ios - 如何在 Xcode 4 中打开界面生成器?

ios - 打开弹出窗口时禁用 tableview 中的滚动

ios - 未调用 UICollectionReusableView 方法

Xcode 9 发行版构建失败,因为新版本中 exportOptions.plist 的格式已更改

ios - 错误 : This app was built with the iOS 12. 0 SDK。从 2019 年 3 月开始,所有提交到 App Store 的 iOS 应用程序都必须使用 iOS 12.1 SDK 构建

ios - 日历事件添加错误时间问题

html - Bootstrap 3 移动键盘解锁导航栏

ios - Nativescript:在设备中启动 iOS 应用程序时崩溃

iphone - NSFetchedResultsController sectionNameKeyPath 等效于 EKEventStore 从 iPhone 日历中获取的事件

ios - 在 EKEvent 中设置选中时间