title: Using dispatch_async to load images in UICollectionView
body: <p>I'm using Parse to store images. I am trying to load the images asynchronously so it does not interfere with the <code>collectionView</code> scroll. I am new to using <code>dispatch_async</code>, and am not so sure how to properly implement it. I've also looked into lazy load, but I thought this would work. But it doesn't, and the <code>collectionView</code> scroll is choppy. Thanks</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
      albumImageCell *cell = (albumImageCell *) [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
  
      if (cell == nil) {
          cell = [[albumImageCell alloc]init];
      }
  
      PFObject *temp = [_dataArray objectAtIndex:indexPath.row];
      PFFile *file = [temp objectForKey:@"image"];
  
      if (cell.hasImage == FALSE) {
          dispatch_async(imageQueue, ^{
              NSData *data = [file getData];
                  if (data) {
                      dispatch_async(dispatch_get_main_queue(), ^(void){
                          cell.imageView.image = [UIImage imageWithData:data];
                          cell.hasImage = TRUE;
                      });
  
                  }
          });
      }
  
      return cell;
  } 
  </code></pre>