ios – 在正常Parse功能的主线程警告上执行长时间运行的操作

首先,我知道这是什么意思.问题是我在无法转换为后台调用的标准调用上收到此错误.我在应用程式开始时遇到这个错误

[Parse enableLocalDatastore];

PFInstallation * currentInstallation = [PFInstallation currentInstallation];

我发现这些方法通过在warnParSEOperationOnMainThread上设置一个符号断点并检查调用堆栈来引起麻烦.

我不能用异步替换这些调用,据我所知,这些方法是从主线程定期调用的.这是一个解析错误,还是应该从后台线程调用所有这些方法

解决方法

将电话转入…
dispatch_async(dispatch_get_global_queue(disPATCH_QUEUE_PRIORITY_DEFAULT,0),^{
    PFInstallation *currentInstallation = [PFInstallation currentInstallation];

        dispatch_async(dispatch_get_main_queue(),^(void){
            // any UI updates need to happen in here back on the main thread
        });
})

您将不再看到警告.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...