title: uiswitch state change issue
body: <p>I have a switch, I want to restrict toggle based on some condition. 
  how can we restrict switch state change based on some condition? I also tried setOn in DispatchQueue.main.async.</p>
  
  <pre><code>if sender.isOn{
        self.pmLabel.textColor = UIColor.ktvPurple()
        self.amLabel.textColor = UIColor.lightGray
  
        if let pmTime = self.eveningShowtime{
          updateClock(from: CGFloat(pmTime), to: CGFloat(pmTime) + CGFloat(durationsHours))
          updatePieChart()
        }else{
          self.view.makeToast("Evening Shows are not available", duration: 1.0, position:CGPoint(x: SCREENWIDTH/2, y: SCREENHEIGHT - 180))
          ampmSwitch.isOn = false
        }
  
      }else{
        self.amLabel.textColor = UIColor.ktvPurple()
        self.pmLabel.textColor = UIColor.lightGray
        if let morningTime = self.morningShowTime{
          updateClock(from: CGFloat(morningTime), to: CGFloat(morningTime) + CGFloat(durationsHours))
          updatePieChart()
        }else{
          self.view.makeToast("Morning Shows are not available", duration: 1.0, position:CGPoint(x: SCREENWIDTH/2, y: SCREENHEIGHT - 180))
          ampmSwitch.isOn = true
  
        }
  
  
  
  
      }
  </code></pre>