title: How to send different data to custom cells in the same UITableView?
body: <p>This is for a blog app  and the issue I'm having is with the layout of the post and its comments.</p>
  
  <p>Ideally the layout would be like this (version 1):</p>
  
  <p><img src="https://i.stack.imgur.com/yTFzL.png" alt="enter image description here"></p>
  
  <p>The parent is a UIScrollView, and all other elements you see are inside it. The UITabelView at the bottom receives the comment thread.</p>
  
  <p>This works, but the problem is with the comments UITableView. I thought I could turn off its scrolling and have it "grow" vertically based on the number of comments. But after a few rows, the content gets clipped. That is because the remaining rows are not being rendered within the vertical size of the UIScrollView.</p>
  
  <p>I've read in SO to do away with the UIScrollView - and instead build the whole thing in a UITableView. Create a custom cell on top to hold the UIImageView, another custom cell below for post text, etc.</p>
  
  <p><strong>Version 2</strong></p>
  
  <p><img src="https://i.stack.imgur.com/eIbqp.png" alt="enter image description here"></p>
  
  <p>My question is: how do you send a specific portion of a JSON feed to populate custom cells, and then iterate through the comments populating the lower cells?</p>
  
  <p>For example the code below sends/iterates comments to the comments UITableView in version 1.</p>
  
  <p>But how would I send the post image or post text to the custom cells in version 2?</p>
  
  <p>Is there a better approach? Any kind of advice is greatly appreciated.</p>
  
  <p><strong>DetailViewController.h</strong> </p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"commentCell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      NSDictionary *post           = self.detailItem;
      NSArray      *commentThread  = [post objectForKey:@"comment"];
      NSDictionary *comment        = [commentThread objectAtIndex:indexPath.row];
  
      NSString     *commentText       = [comment objectForKey:@"comment_text"];
      NSString     *commentAuthorName = [comment objectForKey:@"comment_author_name"];
  
      cell.textLabel.text       = commentText;
      cell.detailTextLabel.text = commentAuthorName;
  
      return cell;
  }
  </code></pre>
  
  <p><strong>JSON</strong></p>
  
  <pre><code>...
  {
      "post_id": "1463",
      "post_title": null,
      "post_text": "dffsdjdflkjklk dlfkjsdlfkj",
      "comment": [
          {
              "comment_author_name": "2162",
              "comment_text": "yuiyuiiopiop",
          },
          {
              "comment_author_name": "2163",
              "comment_text": "tyutyutyutyuu",
          },
          {
              "comment_author_name": "2164",
              "comment_text": "sdfsertertr",
          },
      ]
  },
  ...
  </code></pre>