I'm new to coding and have been attempting to put myself through an intensive course in swift. Right now I'm working on a project that I would like to have a IBAction button that completes "set 1" of instructions on first press, then "set 2" of instructions on second press. Then, press 3 would revert back to "set 1" instructions, press 4 "set 2" and so forth.
Forgive me if this is elementary, but any help would be appreciated.
//Set 1 instructions with the IBAction would be
@IBAction func punchInButtonPressed(sender: AnyObject) {
statusLabel.text = "Status: Punched In"
statusLabel.backgroundColor = UIColor(red: 96/255.0, green: 191/255.0, blue: 111/255.0, alpha: 1.0)
//Set 2 instructions would be
statusLabel.text = "Status: Punched Out"
statusLabel.backgroundColor = UIColor(red: 255/255.0, green: 110/255.0, blue: 115/255.0, alpha: 1.0)
You can handle this by adding a variable to your class that will hold the "state" of the button - punched in or punched out. Then, when the button is pressed, you toggle the state and then display the correct message: