switch in swift 5 code example
Example 1: switch button swift 5
@IBAction func switch(_ sender: Any) {
if ((sender as AnyObject).isOn == true) {
//Yes
} else {
//No
}
}
Example 2: swift switch
for i in 1 ... 100 {
switch (i % 3, i % 5) {
case (0, 0):
print("FizzBuzz")
case (0, _):
print("Fizz")
case (_, 0):
print("Buzz")
default:
print(i)
}
}