title: how to reset seconds to zero in swift whilst timer running
body: <p>Hi guys I've done a simple timer in Swift. All is well apart from when the seconds reach 59 seconds instead of going back to zero they just carry on going. Would someone would be able to point out where I'm going wrong and why this is happening?</p>
  
  <p>this is my code :-</p>
  
  <pre><code>class ViewController: UIViewController {
  
  var startTime = NSTimeInterval()
  var timer = NSTimer()
  var isRunning = false
  
  func updateTime() {
  
      var currentTime = NSDate.timeIntervalSinceReferenceDate()
  
      var elapsedTime : NSTimeInterval = currentTime - startTime
  
      //calculate the minutes in elapsed time
  
      let minutes = UInt8(elapsedTime / 60.0)
      elapsedTime - (NSTimeInterval(minutes) * 60)
  
      //calculate the seconds in elapsed time
  
      let seconds = UInt8(elapsedTime)
      elapsedTime -= NSTimeInterval(seconds)
  
  
      //fraction of milliseconds
  
      let fraction = UInt8(elapsedTime * 100)
  
      //add the leading zero for minutues, seconds and milliseconds, store
      // as string constants
  
      let strMinutes = minutes &gt; 9 ? String(minutes): "0" + String(minutes)
  
      let strSeconds = seconds &gt; 9 ? String(seconds): "0" + String(seconds)
  
      let strFraction = fraction &gt; 9 ? String(fraction): "0" + String(fraction)
  
      //concatonate mins, seoncds and milliseconds, assign to UILable timercount
  
      TimerCount.text = "\(strMinutes):\(strSeconds):\(strFraction)"
  
  }
  
  
  
  @IBOutlet weak var TimerCount: UILabel!
  
  
  @IBAction func StartButton(sender: AnyObject) {
  
      if !timer.valid {
  
          let aSelector : Selector = "updateTime"
  
      timer = NSTimer.scheduledTimerWithTimeInterval(0.01, target: self, selector: aSelector, userInfo: nil, repeats: true)
  
      startTime = NSDate.timeIntervalSinceReferenceDate()
      }
  
  }
  
  
  @IBAction func StopButton(sender: AnyObject) {
  
      timer.invalidate()
  
  }
  
  
  
  
  @IBAction func ResetButton(sender: AnyObject) {
  
          timer.invalidate()
          TimerCount.text = "00:00:00"
  
  }
  </code></pre>