title: Detecting whether UIButton is being pressed with a specific time interval
body: <p>I just want to know whether <code>UIButton</code> is being pressed or not with a specific time interval. (2 sec in my code)
  With a 2 sec period, some value should be 1 if the button is pressed, 2 if not.</p>
  
  <p>In order to check that, I made my code below.
  But <code>unexpected</code> results is coming and I have no idea how I can fix it.
  Help me!</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
      var gameTimer: Timer!
  
  @IBAction func btnClick(_ sender: Any) {
      if let button = sender as? UIButton {
          if (button.isSelected) {
              print(" Not Selected");
          } else {
              print(" Selected");
          }
      }
  }
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      gameTimer = Timer.scheduledTimer(timeInterval: 2, target: self, selector: #selector(btnClick(_:)), userInfo: nil, repeats: true)
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  }
  </code></pre>