title: Passing data from collection view to detail view
body: <p>I need some help figuring out how to pass data from my collection view to the detail view controller. I am starting by simply passing the image through. My code is below:</p>
  
  <p>ViewController:</p>
  
  <pre><code>    -(MyCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  
       MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath];
  
      PFObject *imageObject = [imageFilesArray objectAtIndex:indexPath.row];
      __block UIImage *MyPicture = [[UIImage alloc]init];
      PFFile *imageFile = [imageObject objectForKey:@"test"];
  
  
      [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
          if (!error) {
              MyPicture = [UIImage imageWithData:data];
              cell.CollectionImg.image = [UIImage imageWithData:data];
              cell.cellLabel.text = [object objectForKey:@"phone"];
  
          }
      }];
  
      return cell;
  }
  
   - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
          TopDetailViewController *detailVC = [[TopDetailViewController alloc] initWithNibName:@"TopDetailViewController" bundle:[NSBundle mainBundle]];
          detailVC.img= [imageFilesArray objectAtIndex: indexPath.row];
          [self.navigationController pushViewController:detailVC animated:YES];
      }
  </code></pre>
  
  <p>And the Detail view:</p>
  
  <p>.h</p>
  
  <pre><code>@property (nonatomic, strong) IBOutlet UIImageView *imageView;
  @property (nonatomic, strong) IBOutlet NSString *img;
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>    - (void)viewDidLoad
  {
      [super viewDidLoad];
      self.imageView.image = [UIImage imageNamed:self.img];
      // Do any additional setup after loading the view from its nib.
  }
  </code></pre>
  
  <p>If someone could help me out I would greatly appreciate.</p>