title: Use uicollectionview inside uitableviewcell
body: <p>I can't solve next problem.</p>
  
  <p>I want to display 20 table cells, each contains a unique <code>UICollectionView</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/KfYFT.png" alt="1">
  <img src="https://i.stack.imgur.com/pUp5q.png" alt="2">
  <img src="https://i.stack.imgur.com/aS4Eg.png" alt="3">
  <img src="https://i.stack.imgur.com/hzdhb.png" alt="4">
  <img src="https://i.stack.imgur.com/e4X8N.png" alt="5"></p>
  
  <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
      {
          NSDictionary *package=[_packageList objectAtIndex:indexPath.row];
          static NSString *CellIdentifier = @"package";
          UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
          UICollectionView *cellImageCollection=(UICollectionView *)[cell viewWithTag:9];
          cellImageCollection.restorationIdentifier=[NSString stringWithFormat:@"%li", (long)indexPath.row, nil];
  
          cellTracking.text=[NSString stringWithFormat:@"Row #%li",(long)indexPath.row];
          return cell;
      }
  
  
  -(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
      int row=[collectionView.restorationIdentifier intValue];
      return [[[_packages objectAtIndex:row] valueForKey:@"imageGallery"] count];
  }
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
      int row=[collectionView.restorationIdentifier intValue];
      NSString *imgStrLink=[[[_packages objectAtIndex:row] valueForKey:@"imageGallery"] objectAtIndex:indexPath.row];
      UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ImageID" forIndexPath:indexPath];
      UIImageView *imageView=(UIImageView *)[cell viewWithTag:2];
      imageView.image=....;
      return cell;
  }
  </code></pre>
  
  <p>Function <code>tableView:cellForRowAtIndexPath:</code> is called 20 times, but <code>collectionView:numberOfItemsInSection:</code> and <code>collectionView:cellForItemAtIndexPath:</code> only 4 times.
  As seen in the screenshots <code>UICollectionView</code> is repeated every fourth line.</p>
  
  <p>What is my fault?</p>