简体   繁体   中英

Getting Warning with Parse.com

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM