title: Button in Xcode doesn't change a variable - Swift
body: <p>I am trying to change the value of a variable in Xcode 7 with Swift. For some strange reason, it just doesn't work.</p>
  
  <p>Here are the functions I used.</p>
  
  <pre><code>@IBAction func ten(sender: AnyObject) {
      var percentage = 0.10
      print("test")
  }
  
  @IBAction func twentyBtn(sender: AnyObject) {
      var percentage = 0.20
  }
  
  @IBAction func fifteenBtn(sender: AnyObject) {
      var percentage = 0.15
  }
  
  @IBAction func twentyfiveBtn(sender: AnyObject) {
      var percentage = 0.25
  }
  
  @IBAction func thirtyBtn(sender: AnyObject) {
      var percentage = 0.30
  }
  </code></pre>
  
  <p>Then later in the code I use the percentage variable in this function.</p>
  
  <pre><code>@IBAction func calcTip(sender: AnyObject) {
      var billAmount: Int? {
          return Int(billField.text!)
          }
  
      var tipTotal = percentage * Double((billAmount)!)
  
      toalLabel.text = String(tipTotal)
  
      testLabel.text = String(percentage)
  
  }
  </code></pre>
  
  <p>I don't understand why this shouldn't work because I also have this variable underneath my outlets where at the beggining of the code.</p>
  
  <p>What's even more confusing is that if I try to see if it the button would print into the output, as you see I've tried for the one of the buttons, IT WORKS. Even trying to change the text within a label works, but for some strange reason it won't change a variable.</p>
  
  <p>I'm not sure if this could be a bug with Xcode either.</p>