title: Swift MVC Design With Multiple Table Views
body: <p>So I have the main view of my controller that has a table view. This table view will be displaying many different custom classes that subclass UITableViewCell. Some of these cells will ALSO have table views inside of them.</p>
  
  <p>My problem is that I do not know what class I should assign to to be the UITableViewDelegate in this sort of situation for the table view in the table view cell. My intial thought was to make it the cell view class:</p>
  
  <pre><code>class MyTableViewCell: TableViewCell {
  
      @IBOutlet var tableView: UITableView!;
  
      var messages: Array&lt;String&gt;?;
  
      //called by parent tableview when cellForRowAtIndexPath is called in main controller
      //to initialize view with dynamic properties at run time
      override func render(obj: MyObject) {
          messages = obj.getMessages();
      }
  }
  
  extension MyTableViewCell: UITableViewDataSource {
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
  
      }
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return messages == nil ? 0 : messages!.count;
      }
  }
  </code></pre>
  
  <p>This is problematic because I have no where to register my nib files to the table view:</p>
  
  <p><code>nib = UINib(nibName: "MyTableViewCell", bundle: nil);
  self.tableView.registerNib(nib!, forCellReuseIdentifier: "custom");</code></p>
  
  <p>Also, I feel like making a view a table view data source is violating MVC principles. What is the best way to go about with my table views within table view cells?</p>