ios - 正在主线程上执行长时间运行的 Parse 操作

标签 ios objective-c parse-platform

我收到错误:

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

"Break on warnParseOperationOnMainThread() to debug."

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

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 调用时,这是对开发人员的温和警告。

只有在使用 2015 年以后发布的 Parse API 时,才能在 warnBlockingOperationOnMainThread 上添加一个符号断点。否则,将其放在 warnParseOperationOnMainThread 上。

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

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

enter image description here

enter image description here

关于ios - 正在主线程上执行长时间运行的 Parse 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20988960/

相关文章:

iphone - 检查 View 是否在运行时加载

ios - 可以解析缓存替换核心数据

java - 如何在 Parse whereWithinMiles 函数上使用关系数据?

swift - 快速解析使用(Tableview)

iphone - iPhone 中可以添加多少条记录?

objective-c - 在 UITableView Objective-C 中滚动更改数据

ios - 允许免费试用 App Store 订阅吗?

ios - 删除适当的图像

ios - 来自 UITableView 的 View 消失

objective-c - 您应该如何处理 NSStream 阻塞的可能性?