This may be a bit of a silly question, but I'm looking for a reliable way to create a repeating timer in Swift that's as completely accurate as possible. I've researched this quite a bit and have found that the mach_absolute_time api seems to be what I'm looking for.
However, while I think I understand mach_absolute_time, there's not much out there on mach_wait_until (if I understand correctly that's the mach api version of using Timer.scheduledTimer()
to call a selector).
So my goal is to turn something like Martin R's answer to this post: Measuring Time Accurately in Swift for Comparison Across Devices into a timer that can measure out an exact amount of time, call a selector, and repeat with little to no loss of time between ticks.
Thanks!
Update
The other thing I ran into is that the timer can't lock up the app while the it's running either – I know since mach is pretty low level, calling mach_wait_until will stop everything else and wait for the time to elapse (I think).