-1

Is there a way to create a timer that performs just like the Fitness app on watchOS or Clock app on iOS? More specifically, is there a dedicated SDK that lets you create timers with Swift? What's the suggested approach to doing that?

I know about the Timer class, but Timer only lets you listen for one-second changes, while the above-mentioned apps both have milliseconds timer.

Thanks!

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
maticzav
  • 880
  • 9
  • 17
  • You surely tried _something_. SO is not a free code writing website. Without showing at least some (research) effort, you're highly unlikely to receive an answer here. – Dávid Pásztor Mar 11 '21 at 12:29

1 Answers1

1

You can use Timer and set the TimeInterval which really is in seconds, but which is also an alias for double.

typealias TimeInterval = Double

This means you can put there value such as 0.02. Also remember, that timer might not be triggered precisely at the interval. There is a

var tolerance: TimeInterval

  • The amount of time after the scheduled fire date that the timer may fire.

that can be configured for a timer instance.

For more info see https://developer.apple.com/documentation/foundation/timer

vytick
  • 166
  • 5