Timers.swift 629 B

123456789101112131415161718192021
  1. // LoopFollow
  2. // Timers.swift
  3. import Foundation
  4. import UIKit
  5. extension MainViewController {
  6. func startGraphNowTimer(time: TimeInterval = 60) {
  7. graphNowTimer.invalidate()
  8. graphNowTimer = Timer.scheduledTimer(timeInterval: time,
  9. target: self,
  10. selector: #selector(MainViewController.graphNowTimerDidEnd(_:)),
  11. userInfo: nil,
  12. repeats: true)
  13. }
  14. @objc func graphNowTimerDidEnd(_: Timer) {
  15. chartModel.rebuild()
  16. }
  17. }