2014-10-08 74 views
0

我正在試圖訪問NSArray槽enumerateObjectsUsingBlock上的每個項目,因爲它讓我使用快速枚舉和評估索引。Parse.com獲得警告

當我使用findObjectsInBackgroundWithBlock,

我得到警告:長時間運行的操作被主 線程執行。斷開warnBlockingOperationOnMainThread()進行調試。

正如我以爲在背景中使用不阻止Mainthread。這裏是我的代碼和我正在試圖實現它,我有兩個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; 
       } 
      }]; 
     } 
    }]; 

回答

0

故障排除我的代碼,我意識到findObjectsInBackgroundWithBlock不會導致此警告。

在我的代碼另一部分我有這樣的:

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

哪個塊主線程。

我很抱歉。