title: Pass variables from one ViewController to another in Swift
body: <p>I have a calculator class, a first ViewController to insert the values and a second ViewController to show the result of the calculation. Unfortunately I get a error called "Can't unwrap Optional.None" if I click the button. I know it's something wrong with the syntax, but I don't know how to improve it.</p>
  
  <p>The button in the first Viewcontroller is set to "Segue: Show (e.g. Push)" in the storyboard to switch to the secondViewController if he gets tapped. </p>
  
  <p>the calculator class is something like:</p>
  
  <pre><code>class Calculator: NSObject {
  
      func calculate (a:Int,b:Int) -&gt; (Int) {
          var result = a * b
          return (result)
      }
  }
  </code></pre>
  
  <p>The Viewcontroller calls the function, inserts a/b and wants to change the label which is located in the secondviewcontroller:</p>
  
  <pre><code>class ViewController: UIViewController {
  
  @IBAction func myButtonPressed(sender : AnyObject) {
      showResult()
  }
  
  var numberOne = 4
  var numberTwo = 7
  
  var myCalc = Calculator()
  
  func showResult () {
      var myResult = myCalc.calculate(numberOne, b: numberTwo)
      println("myResult is \(String(myResult))")
      var myVC = secondViewController()
      myVC.setResultLabel(myResult)
  }
  </code></pre>
  
  <p>And here is the code of the secondViewController</p>
  
  <pre><code>class secondViewController: UIViewController {
  
  @IBOutlet var myResultLabel : UILabel = nil
  
  func setResultLabel (resultValue:Int) {
      myResultLabel.text = String(resultValue)
  }
  
  init(coder aDecoder: NSCoder!)
  {
      super.init(coder: aDecoder)
  }
  </code></pre>