Getting Warning with Parse.com

213 Views Asked by At

I'm triying to access each item on an NSArray trough enumerateObjectsUsingBlock, since it let me use fast enumration and evaluating the index.

When I use findObjectsInBackgroundWithBlock,

I get Warning: A long-running operation is being executed on the main thread. Break on warnBlockingOperationOnMainThread() to debug.

As I thought was used in the background to not block the Mainthread. Here is my code and what I'm triying to achieve its that I have two UIImageView container that I'm pulling the images from the result of the relation on that query. Since there are only container I tought it was better just to evaluate the index of NSArray.

Not sure how I can remedy that warning.

Thanks

    [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;
                }
            }];
        }
    }];
1

There are 1 best solutions below

0
outime On BEST ANSWER

Troubleshooting my code, I realized that findObjectsInBackgroundWithBlock does not cause this warning.

On another part of my code I had this:

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

Which block the main thread.

I apologize.