title: Dynamic UITableView Datasource inside of Static UITableView Cell
body: <p>There's probably a better way to do this, but I've been googling all day and can't find a solution to my specific problem:</p>
  
  <p>I have a static TableView which displays a fair amount of information and includes a text entry portion to add values to a dynamic TableView nested in one of the cells of the parent static TableView.  </p>
  
  <p>To do this, I have a subclass of UITableViewDataSource and UITableViewDelegate inside of my UITableViewController which will control what is displayed in the nested TableView.  I have an outlet to the nested table:</p>
  
  <pre><code>@IBOutlet weak var validatedCardsTable: UITableView!
  </code></pre>
  
  <p>In my <code>viewDidLoad</code> have:</p>
  
  <pre><code>let dataSource = ValidatedCardsDataSource(tableView: self.validatedCardsTable)
  self.validatedCardsTable.dataSource = dataSource
  self.validatedCardsTable.delegate = dataSource
  </code></pre>
  
  <p>and my subclass looks like this: </p>
  
  <pre><code>class ValidatedCardsDataSource :NSObject, UITableViewDataSource, UITableViewDelegate {
  
      var tableView:UITableView
  
      init(tableView : UITableView) {
          self.tableView = tableView
          super.init()
      }
  
      func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat {
          return 100
      }
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
          return 1
      }
  
      func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
          return 1
      }
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = self.tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as UITableViewCell
          cell.textLabel!.text = "Title of Row: #\(indexPath.row)"
          return cell
      }
  }
  </code></pre>
  
  <p>When I run this code, the nested TableView loads the appropriate "Title of Row" text that I am setting in <code>cellForRowAtIndexPath</code> (although the tableview isn't resizing, another issue altogether I'm sure).  However, when I press down on the TableView anywhere, a label I have designated "A Label" in the cell prototype in my storyboard shows on the cell as well, and then when I release the press, all formatting disappears and the cell reverts back to default state.  I'm assuming that I'm not fully hooking something up somewhere, but any help you can give in tracking down what I'm doing wrong, or suggesting a better way to handle this would be much appreciated! Screenshots below: </p>
  
  <p>Prototype Cell:</p>
  
  <p><img src="https://i.imgur.com/f9ERbLc.jpg" alt="Prototype Cell"></p>
  
  <p>What shows on load:</p>
  
  <p><img src="https://i.imgur.com/A65n8Kp.jpg" alt="loaded"></p>
  
  <p>What shows on touch down:</p>
  
  <p><img src="https://i.imgur.com/Cyu7llm.jpg" alt="loaded"></p>
  
  <p>What shows on touch up:</p>
  
  <p><img src="https://i.imgur.com/DbXR9mV.jpg" alt="loaded"></p>