title: iOS: numberOfSectionsInCollectionView message sent to deallocated instance
body: <p>I have this code to manage a collectionview  </p>
  
  <pre><code>- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  {
      return  1;
  }
  
  - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  {
      return [images count];
  }
  
  - (PhotoCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  
      PhotoCell *cell = [gridPhoto dequeueReusableCellWithReuseIdentifier:@"photocell" forIndexPath:indexPath];
  
      NSMutableDictionary *record = [images objectAtIndex:[indexPath row]];
      if ([record valueForKey:@"actualImage"]) {
          [cell.image setImage:[record valueForKey:@"actualImage"]];
          [cell.activity stopAnimating];
      } else {
          dispatch_async(imageQueue_, ^{
              NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[record objectForKey:@"url"]]];
              dispatch_async(dispatch_get_main_queue(), ^{
                  [record setValue:[UIImage imageWithData:imageData] forKey:@"actualImage"];
                  [collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
              });
          });
      }
  
      return cell;
  }
  </code></pre>
  
  <p>It work fine if the imageQueue_ finish its work and populate the entire collectionview; I have a problem when I exit from my view calling a back</p>
  
  <pre><code>- (IBAction)back:(id)sender{
      [self.navigationController popViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>In this case if the collectionview is not entire populated of images I have this error when I do back action:</p>
  
  <pre><code>[PhotoGalleryViewController numberOfSectionsInCollectionView:]: message sent to deallocated instance 0x1590aab0
  </code></pre>
  
  <p>where is the problem?</p>