I'm tying to get a heart throbbing animation to match the heart-rate sampled form HealthKit in WatchOS2. I can't seem to find a way to update the timer interval based upon more recent samples.
After a bit of research, invalidating the timer and rescheduling is the recommended method; but the following bit of code doesn't seem to get the job done.
class InterfaceController: WKInterfaceController {
var timer: NSTimer?
private func updateHeartRate(rate: Int) {
...
heartBeatIntensity = NSTimeInterval(0.0166 * Float(rate))
print(heartBeatIntensity)
if let timer = timer {
timer.invalidate()
}
timer = NSTimer.scheduledTimerWithTimeInterval(heartBeatIntensity, target:self, selector: Selector("updatesByTimer"), userInfo: nil, repeats: true)
}