I made a function where each time a button is pressed, a number increases by 1. I want to make a function to reset the number back to 0 but can’t figure it out for the life of me and can’t find it online.
Can anyone help me fill in the function?
My code is as follows:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var backgroundImageView: UIImageView!
@IBOutlet weak var greenButton: UIButton!
@IBOutlet weak var labelQuestion: UILabel!
@IBOutlet weak var numberHit: UILabel!
@IBOutlet weak var reset: UIButton!
var buttonScore = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func buttonHit(_ sender: Any) {
//Make the score increase by 1 each time the greenButton is hit
buttonScore += 1
numberHit.text = String (buttonScore)
}
@IBAction func reset(_ sender: Any) {
//Reset the number back to zero when pressed
}
}
Appreciate any help. Thank you!