I am trying to learn swift and have a problem with segmented controls.
I have an IBAction which will use switch to select 'Male' or 'Female'.
Here is the code:
However I get an error on the switch line:
I have looked on the web and the method looks OK to me, so why do I get this error?
I have an IBAction which will use switch to select 'Male' or 'Female'.
Here is the code:
Code Block @IBAction func genderButton(_ sender: UISegmentedControl) { switch segmentedControl.selectedSegmentIndex { case 0: userGender = "Female" case 1: userGender = "Male" default: return } }
However I get an error on the switch line:
Code Block Cannot find 'segmentedControl' in scope
I have looked on the web and the method looks OK to me, so why do I get this error?