diff --git a/StopWatch/Base.lproj/Main.storyboard b/StopWatch/Base.lproj/Main.storyboard index dd9d164..1b6c085 100644 --- a/StopWatch/Base.lproj/Main.storyboard +++ b/StopWatch/Base.lproj/Main.storyboard @@ -1,6 +1,6 @@ - + @@ -14,7 +14,7 @@ - + @@ -27,7 +27,7 @@ - - - + - + + + + + + diff --git a/StopWatch/TimerModel.swift b/StopWatch/TimerModel.swift index 56e5eeb..d85e361 100644 --- a/StopWatch/TimerModel.swift +++ b/StopWatch/TimerModel.swift @@ -31,9 +31,12 @@ class TimerModel { func startTimer() -> Void { self.startTime = Date() - self.timer = Timer(timeInterval: 0.01, repeats: true, block: { (_) in + // don't worry about runloop details, we'll talk about it later + let timer = Timer(timeInterval: 0.01, repeats: true, block: { (_) in let elapsedTime = self.timeSinceStart() self.updateDelegate.map { $0.timeUpdated(elapsedTime) } }) + self.timer = timer + RunLoop.current.add(timer, forMode: .default) } } diff --git a/StopWatch/ViewController.swift b/StopWatch/ViewController.swift index 68a710b..3fcd0a2 100644 --- a/StopWatch/ViewController.swift +++ b/StopWatch/ViewController.swift @@ -10,7 +10,7 @@ import UIKit class ViewController: UIViewController, UpdateTime { func timeUpdated(_ interval: TimeInterval) { - // set our label + print(interval) }