title: Toggle UISwitch on/off in swift
body: <p>I'm having an issue toggling a UISwitch on/off. </p>
  
  <p>When the switch labeled "blood glucose" is turned on, the switch below it, labeled "HbA1c" is turned off. And vice-versa. Flip "blood glucose" off, "HbA1c" is turned on. It works fine.</p>
  
  <p>However, using the same code, the "HbA1c" UISwitch does not toggle its partner "blood glucose" on/off. I'm puzzled why the code works for one UISwitch but not the other. </p>
  
  <p>The IBAction a1cSwitchPressed is connected properly, I stuck a label update in the function which worked.</p>
  
  <p><a href="https://i.stack.imgur.com/pGWAZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pGWAZ.png" alt="uiswitch toggle"></a></p>
  
  <pre><code>@IBAction func eagSwitchPressed(_ sender: UISwitch) {
   a1cSwitch.setOn(!sender.isOn, animated: true)     
  }
  
  @IBAction func a1cSwitchPressed(_ sender: UISwitch) {
   eagSwitch.setOn(!sender.isOn, animated: true)
  }
  </code></pre>