
The program should change F TO C and vice versa. With the switch, it changes from on and off, which means it should be from C to f and off from F to c and enter # under the text box. When you click the Submit button, it accepts the fact that in a text field it passes it to the algorithm prefix, and then it displays it in the text field.
I believe that the conversion is going right, but does not display the actual result. Or how his conversion is wrong.
@IBOutlet weak var buttonClicked: UIButton! @IBOutlet weak var mySwitch: UISwitch! @IBOutlet weak var myTextField: UITextField! @IBOutlet weak var User: UITextField! func stateChanged(switchState: UISwitch) { if switchState.on { myTextField.text = "Convert to Celius" } else { myTextField.text = "Convert to Farheniet" } } @IBAction func buttonClicked(sender: UIButton) { if mySwitch.on { var a:Double? = Double(User.text!) a = a! * 9.5 + 32 User.text=String(a) mySwitch.setOn(false, animated:true) } else { var a:Double? = Double(User.text!) a = a! * 9.5 + 32 User.text=String(a) mySwitch.setOn(true, animated:true) } }
Sonny source share