title: Swift/Objective-C: How to call a view-controller-method from another class
body: <p>Lets say I have a class called <code>FooController</code>. It will at some point in time call the method <code>bar(str: String)</code> owend by the second class <code>BarController</code>. <code>BarController</code> is a subclass of <code>NSViewController</code> and has an <code>IBOutlet</code>. This outlet is connected to a <code>NSButton</code>.</p>
  
  <p><code>bar</code> simply changes the text of the button to some string like "Example".</p>
  
  <p>My first approach was to create a new instance of <code>BarController</code> and then calling the method.</p>
  
  <pre><code>var bc = BarController()
  bc.bar("Example")
  </code></pre>
  
  <p>My problem is, that the new instance is not connectet to the interface and so the <code>IBOutlet</code> becomes <code>nil</code>.</p>
  
  <pre><code>func bar(str: String) {
      myButton.title = str // myButton is nil
  }
  </code></pre>