Alright I had the exact same problem on devices running iOS 13, and when I started running Xcode 11. The problem (for me at least) was that Apple (probably) made a bug fix for the issue with the "valueChanged" hook to a UISwitch, see:
Either way, what happened before was that the action for the switch got triggered twice, so I (apparently) set the switch to the right state myself. Like this:
@IBAction func notificationsSwitchTapped(_ sender: UISwitch) {
if sender.isOn{
sender.setOn(false, animated: true)
}else{
sender.setOn(true, animated: true)
}
}
But as of iOS 13 Xcode 11, the "valueChanged" UISwitch bug got fixed and the .isOn() value I am checking, actually already is the new value:
@IBAction func notificationsSwitchTapped(_ sender: UISwitch) {
if sender.isOn{
// The switch has been turned on
}else{
// The switch has been turned off
}
}
Long story short, your switch probably got called twice before so your Boolean of the UISwitch's state is the opposite for your Xcode 11 iOS 13 code.