Last active
July 1, 2020 12:39
-
-
Save tonnylitao/72b3c5756e59293cb50a917fbe761867 to your computer and use it in GitHub Desktop.
Listen to event and change model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func nameChanged(_ sender: UITextField) { | |
model.name = sender.text | |
} | |
@IBAction func emailChanged(_ sender: UITextField) { | |
model.email = sender.text | |
} | |
@IBAction func switchChanged(_ sender: UISwitch) { | |
model.likeKiwi = sender.isOn | |
} | |
@IBAction func hobbySelected(_ sender: UIButton) { | |
sender.isSelected.toggle() | |
let isSelected = sender.isSelected | |
if sender.tag == 1 { | |
model.travel = isSelected | |
}else if sender.tag == 2 { | |
model.hiking = isSelected | |
}else if sender.tag == 3 { | |
model.reading = isSelected | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment