title: Load image to UICollectionView Asynchronously?
body: <p>How can i load images to a <code>UICollectionview</code> asynchronously?
  Inside following method?</p>
  
  <pre><code>- (PSTCollectionViewCell *)collectionView:(PSTCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  
   bookImage = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", docPath, [[preview objectAtIndex:indexPath.row] lastPathComponent]]];
   [[cell grid_image] setImage:bookImage];
  
  }
  </code></pre>
  
  <p>In <strong>viewdidload()</strong> i am using following asynch call to load images to "preview "<code>NSMutablearray</code></p>
  
  <pre><code> dispatch_queue_t imageLoadQueue = dispatch_queue_create("com.GMM.assamkar", NULL);
  
  dispatch_async(imageLoadQueue, ^{
      //Wait for 5 seconds...
      usleep(1000000);
      docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
  
  
      for(int k=0; k &lt;[allImage count] ;k++){
  
  
          imgURL = [allImage objectAtIndex:k];
          [imagePreview addObject:imgURL];
          imgData=[NSData dataWithContentsOfURL:[NSURL URLWithString:imgURL]];
  
  
          [imgData writeToFile:[NSString stringWithFormat:@"%@/%@", docPath, [allImage lastPathComponent]] atomically:YES];
  
      }
  
      [[self collectionView] reloadData];
  
  
  });
  </code></pre>
  
  <p>Please help me..Now its taking too much time for loading...</p>