switch button in swift code example
Example 1: switch statements swift
var x = 1
switch x {
case 0: // if x = 0
print("x = 0")
case 1: // if x = 1
print("x = 1")
default: // if x is not 0 nor 1
print("no x value")
}
Example 2: switch button swift 5
@IBAction func switch(_ sender: Any) {
if ((sender as AnyObject).isOn == true) {
//Yes
} else {
//No
}
}