Kotlin: call a function every second : <p>I want to create a simple countdown for my game, when the game starts I want this function to be called every second:</p>

<pre><code>fun minusOneSecond(){
  if secondsLeft &gt; 0{
     secondsLeft -= 1
     seconds_thegame.text = secondsLeft.toString()
  }
}
</code></pre>

<p>I tried this:</p>

<pre><code>var secondsLeft = 15

timer.scheduleAtFixedRate(
   object : TimerTask() {

      override fun run() {
         minusOneSecond()
      }

    },0, 1000
)   // 1000 Millisecond  = 1 second
</code></pre>

<p><strong>But the app unfortunately stops, the 2nd time the run function is called</strong></p>

<p>I just started with android development and Kotlin 3 weeks ago and so far I understand the most out of it.</p>

<p>With swift in Xcode I use this line and I thought something similar would work with Kotlin</p>

<pre><code>setTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(minusOneSecond), userInfo: nil, repeats: true)
</code></pre>
