title: Disable Button from another view controller with a switch with swift
body: <p>Ok so I am trying to make it when the user flips the cheat mode switch it will disable the answerButton. I did try to set the button to disable near the bottom however it does not appear to do anything. I added the print("") to see if it would print in the console however nothing was printed. I a unsure what is wrong here.  </p>
  
  <p>I have pasted my code below.</p>
  
  <pre><code>import Foundation
  import UIKit
  
  
  class SettingsController: UITableViewController {
  
  @IBOutlet weak var cheatSwitch: UISwitch!
  
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      cheatSwitch.isOn = UserDefaults.standard.bool(forKey: "switchState")
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  @IBAction func saveSettings(_ sender: UISwitch) {
      UserDefaults.standard.set(cheatSwitch.isOn, forKey: "switchState")
      UserDefaults.standard.synchronize()
  }
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      let mainView : ViewController = segue.destination as! ViewController
  
      if cheatSwitch.isOn == true {
          print("turn off button")
          mainView.btnAnswer.isEnabled = false;
  
      }
  
      else {
          print("turn on button")
          mainView.btnAnswer.isEnabled = true;
      }
  
  
  }
  </code></pre>
  
  <p>}</p>