title: Swift can't call protocol method via delegate
body: <p>I have two classes. One class is named <code>ViewController</code> and the other class is named <code>TabView</code>.</p>
  
  <p>My goal is to call a function <code>changeTab()</code> which is inside the TabView class from the ViewController.</p>
  
  <p>Somehow I am having trouble with it because everytime my delegate is <code>nil</code>.</p>
  
  <p><strong>Here is my code for ViewController:</strong></p>
  
  <pre><code>protocol TabViewProtocol: class {
      func changeTab() 
  }
  
  class ViewController: NSViewController {
      // delegate
      weak var delegateCustom : TabViewProtocol?
  
      override func viewDidLoad() {
          print(delegateCustom) // outputs "nil"
      }
  
      buttonClickFunction() {
          print(delegateCustom) // outputs "nil"
          delegateCustom?.changeTab() // doesn't work
      }
  }
  </code></pre>
  
  <p><strong>Here is my code for TabView:</strong></p>
  
  <pre><code>class TabView: NSTabViewController, TabViewProtocol {
  
      let myVC = ViewController()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          myVC.delegateCustom = self
      }
  
      func changeTab() {
          print("test succeed")
      }
  }
  </code></pre>
  
  <p>Can someone explain me what I am doing wrong? - I am new to delegates and protocols...</p>