-3

I connected the UILabel and UIButton but is still aborts. Please help me fix this.

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        counterLabel.text = "0"
        // Do any additional setup after loading the view, typically from a nib.
    }
    var counterNum: Int = 0

    @IBOutlet weak var counterLabel: UILabel!

    @IBAction func Tap(_ sender: UIButton) {

        self.counterNum += 1
        self.counterLabel.text = String(self.counterNum)
    }
}
Giuseppe Lanza
  • 3,519
  • 1
  • 18
  • 40

1 Answers1

0

Please check your outlet connect in your storyboard for counterLabel. It seems you forget to do the outlet connection.

KGen
  • 50
  • 3