title: How to link a boolean value to the on/off state of a UISwitch?
body: <p>I have a <code>UISwitch</code> that I want to control a boolean value in a function I wrote. I looked in the <code>UISwitch</code> Type Reference and it listed the property for the on/off state of the switch as <code>on</code>. I tried to use this in a action:</p>
  
  <pre><code>@IBAction func switchValueChanged(sender: UISwitch) {
          if acsessabilitySwitch.on {
  //accessibilitySwitch is the UISwitch in question 
              println("It's True!")
              advice.isInProduction = Bool (true) 
  // isInProduction is a attribute of a class
          } else {
              println("It's False!")
              advice.isInProduction = Bool (false)
          }
  </code></pre>
  
  <p>but when I ran it and hit the switch it crashed and didn't print anything.</p>
  
  <p>EDIT:
  Here is my ViewController and my custom class files:</p>
  
  <p>BuyingAdviceModel.swift:</p>
  
  <pre><code>import Foundation
  class videoGameModel{
      var price : Double
      var isInProduction : Bool
      var adviceGiven: String?
      init (isInProduction : Bool, price: Double){
          self.price = price
          self.isInProduction = isInProduction
      }
      func giveAdvice (price:Double, isInProduction:Bool)-&gt;(adviceGiven:String){
              if price &gt;= 199.99 {
                  var adviceGiven = "Nope, that's too expensive!"
                  return adviceGiven
              } else if price &lt;= 99.99{
                  if isInProduction == true {
                      var adviceGiven = ("Buy it at GameStop!")
                      return adviceGiven
                  } else {
                      var adviceGiven = ("Go look online!")
                      return adviceGiven
                  }
              } else {
                  var adviceGiven = ("Are you sure you put the info in correctly?")
                  return adviceGiven
              }
      }
  }
  </code></pre>
  
  <p>ViewController.swift:</p>
  
  <pre><code>import UIKit
  import Foundation
  class ViewController: UIViewController {
      @IBOutlet var priceTextField: UITextField
      @IBAction func adviceButtonTapped(sender: AnyObject) {
          let adviceOutputed = advice.adviceGiven!
          adviceLabel.text=adviceOutputed
      }
      @IBAction func viewTapped(sender: AnyObject) {
          priceTextField.resignFirstResponder()
      }
  
       @IBOutlet var acsessabilitySwitch: UISwitch
       @IBOutlet var adviceLabel: UILabel
       @IBAction func switchValueChanged (sender: UISwitch) {
          advice.isInProduction = sender.on
          println ("It's " + advice.isInProduction.description + "!")
      }
      var advice = videoGameModel (isInProduction: true,price: 0.00)
      func refreshUI(){
          priceTextField.text = String(advice.price)
          adviceLabel.text = ""
      }
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          refreshUI()
      }
  
      override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
      }
  
  
  }
  </code></pre>