Check out example codes for "switches xcode". It will help you in understanding the concepts better.

Code Example 1

@IBAction func switchO(_ sender: Any) {
        if ((sender as AnyObject).isOn == true) {
        labelO.text = "Yes I Do" } else {
        labelO.text = "No I Do Not"
    }  
}

Learn ReactJs, React Native from akashmittal.com