We can use the isOn property of your switch to do this:
if (flickSwitch isOn) { statusLabel.text = @"The Switch is ON"; } else { statusLabel.text = @"The Switch is OFF"; }
Alternatively we can use the square-bracket notation like so:
if ([flickSwitch.isOn]) { statusLabel.text = @"The Switch is ON"; } else { statusLabel.text = @"The Switch is OFF"; }
You know what it’s like… a few months later this doesn’t work anymore, or it’s the other way round. I H-A-T-E Xcode and this Objective-C 5H1T so very very very much.
That aside, here’s another solution which works (today that is):
There is another way by checking if the sender’s property isOn or not, like so:
This is useful if you don’t want to define the switch as a property. All you need to do is connect it to an action which will check the above.