title: Using timers in swift
body: <p>I am a complete beginner and am starting to learn the Swift programming language. I'm following a tutorial on Udemy and am having some problems with setting up a timer. </p>
  
  <pre><code>class ViewController: UIViewController {
  @IBOutlet weak var label: UILabel!
  var timer1 = Timer()
  var counter = 0
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view.
  
      label.text = String(counter)
  
  
  
  }
  @IBAction func start(_ sender: Any) {
  
      timer1 = Timer(timeInterval: 1, target: self, selector: #selector(tim), userInfo: nil, repeats: true)
  
  
  
  }
  
  @IBAction func pause(_ sender: Any) {
  
      timer1.invalidate()
  
  }
  
  @IBAction func restart(_ sender: Any) {
  
      timer1.invalidate()
      counter = 0
      label.text = String(counter)
  
  }
  
  @objc func tim() {
  
      counter += 1
      label.text = String(counter)
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is my code but the timer is not working. Please tell me where im going wrong.</p>