【问题标题】:Getting Warning with Parse.com使用 Parse.com 获得警告
【发布时间】:2014-10-08 00:58:38
【问题描述】:

我正在尝试通过 enumerateObjectsUsingBlock 访问 NSArray 槽上的每个项目,因为它让我可以使用快速枚举和评估索引。

当我使用 findObjectsInBackgroundWithBlock 时,

我收到警告:正在主服务器上执行长时间运行的操作 线。中断 warnBlockingOperationOnMainThread() 进行调试。

正如我认为在后台使用的那样不阻塞主线程。这是我的代码,我正在努力实现它,我有两个 UIImageView 容器,我从该查询的关系结果中提取图像。由于只有容器,我认为最好只评估 NSArray 的索引。

不知道如何解决这个警告。

谢谢

    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (objects != 0) {
            [objects enumerateObjectsUsingBlock:^(PFUser *object, NSUInteger idx, BOOL *stop) {
                if (idx == 0) {
                    PFFile *userProfile = [object objectForKey:@"userPic"];
                    cell.promoter1.file = userProfile;
                    cell.promoter1.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.promoter1 loadInBackground];                                                                                    
                    cell.promoter1Name.textAlignment = NSTextAlignmentCenter;
                    cell.promoter1Name.lineBreakMode = NSLineBreakByWordWrapping;
                }
                if (idx == 1) {
                    PFFile *userProfile = [object objectForKey:@"userPic"];

                    cell.promoter2.file = userProfile;
                    cell.promoter2.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.promoter2 loadInBackground];
                    NSAttributedString *promoter1Name;                                                                                  
                    cell.promoter2Name.textAlignment = NSTextAlignmentCenter;
                    *stop = YES;
                }
            }];
        }
    }];

【问题讨论】:

    标签: ios objective-c parse-platform cell fast-enumeration


    【解决方案1】:

    对我的代码进行故障排除后,我意识到findObjectsInBackgroundWithBlock 不会导致此警告。

    在我的代码的另一部分我有这个:

    PFUser *user = [PFQuery getUserObjectWithId:@"ebwFrl8PcF"];    
    [relation addObject:user];
    [self.event saveInBackground];
    

    哪个阻塞了主线程。

    我很抱歉。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-30
      • 1970-01-01
      • 2015-12-30
      • 2022-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多