主线程上正在执行长时间运行的 Parse 操作 [英] A long-running Parse operation is being executed on the main thread

查看:21
本文介绍了主线程上正在执行长时间运行的 Parse 操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:

正在主线程上执行长时间运行的解析操作.中断warnParseOperationOnMainThread() 进行调试."

"A long-running Parse operation is being executed on the main thread. Break on warnParseOperationOnMainThread() to debug."

中断warnParseOperationOnMainThread() 进行调试."

"Break on warnParseOperationOnMainThread() to debug."

我无法在我的代码中找到错误.有人可以告诉我我做错了什么吗?

I'm unable to locate the error within my code. Can someone please tell me what I'm doing wrong?

PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query getObjectInBackgroundWithId:[[PFUser currentUser] objectId] block:^(PFObject *object, NSError *error) {

    self.firstName = object[@"firstname"];
    self.lastName = object[@"lastname"];

    self.nameLabel.text = [[NSArray arrayWithObjects:self.firstName, self.lastName, nil] componentsJoinedByString:@" "];
}];

推荐答案

这是对开发人员进行会阻塞主线程的 Parse 调用时的温和警告.

This is a gentle warning to the developers when they make the Parse calls that would block the main thread.

这是您可以看到这一切发生的地方,仅当您使用 2015 年以后发布的 Parse API 时,才在 warnBlockingOperationOnMainThread 上添加一个符号断点.否则,将其放在 warnParseOperationOnMainThread 上.

This is where you can see it all happen,, add a symbolic breakpoint on warnBlockingOperationOnMainThread only if you use a Parse API released from 2015+. Otherwise, put it on the warnParseOperationOnMainThread.

它会在您运行代码时中断该函数,并向您显示一个堆栈跟踪,它应该可以帮助您找到阻塞函数.

It'll break on that function while you are running your code, and will show you a stack trace which should help you to find the blocking function.

请参阅下面的图片以更好地理解.

See the images below to have a better understanding.

这篇关于主线程上正在执行长时间运行的 Parse 操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆