问题描述
首先,我知道这意味着什么。问题是我在无法转换为后台调用的标准调用上遇到此错误。我在app开始时收到此错误:
First of all, I know what this means. The problem is that I'm getting this error on standard calls that can't be converted to background calls. I'm getting this error on app start at:
[Parse enableLocalDatastore];
PFInstallation * currentInstallation = [PFInstallation currentInstallation];
我发现通过在 warnParseOperationOnMainThread
上设置符号断点并检查调用堆栈,这些方法导致了问题。
I've found out that these methods are causing the trouble by setting a symbolic breakpoint on warnParseOperationOnMainThread
and examining the call stack.
我不能用异步的那些替换这些调用,据我所知,这些方法 意味着要定期从主线程。这是一个Parse错误,还是应该从后台线程中调用所有这些方法?
I can't replace these calls with async ones, and as far as I know, these methods are meant to be called regularly from the main thread. Is this a Parse bug, or should I call all these methods from a background thread?
推荐答案
将呼叫包裹在...
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
});
})
您将不会再看到警告。
这篇关于正常Parse函数上的主线程警告正在执行长时间运行的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!