loading images from a background thread using blocks

you could implement something like this in your cellForRowAtIndexPath:

That way you load each image in the background and as soon as its loaded the corresponding cell is updated on the mainThread.

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) {
        NSData *data0 = [NSData dataWithContentsOfURL:someURL];
        UIImage *image = [UIImage imageWithData:data0];

        dispatch_sync(dispatch_get_main_queue(), ^(void) {
            UIImageView* imageView = (UIImageView*)[cell viewWithTag:100];
            imageView.image = image;
        });
    });

Leave a Comment