title: How to add reusable custom views programmatically? (Swift)
body: <p>I've created a reusable xib file that contains a table and it's being loaded in a <code>TableView.swift</code> file like this:</p>
  
  <pre><code>required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)    
      Bundle.main.loadNibNamed("TableView", owner: self, options: nil)
  }
  </code></pre>
  
  <p><em>I'm only mentioning this to clarify that I am not confused about how to load the xib file</em></p>
  
  <hr>
  
  <p>I can easily load the reusable view in my <code>RootViewController.swift</code> file by adding a view to the <code>UIViewController</code> and giving that view a custom class like this:</p>
  
  <p><a href="https://i.stack.imgur.com/fALX8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fALX8.png" alt="enter image description here"></a></p>
  
  <p>and then creating an outlet for that view like this:</p>
  
  <p><a href="https://i.stack.imgur.com/7w8kM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7w8kM.png" alt="enter image description here"></a></p>
  
  <p><strong>So here is my question:</strong></p>
  
  <p>Why am I not able to simply add the view like this:</p>
  
  <pre><code>let tableViewView = TableView()
  </code></pre>
  
  <p>When I do, I get an error that I don't totally understand:</p>
  
  <p><a href="https://i.stack.imgur.com/BUIGf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BUIGf.png" alt="enter image description here"></a></p>