How to accurately time "click" intervals in swift/iOS

2020-02-14 ios swift timer intervals

How can I accurately time "click" intervals in Swift/iOS? My online search suggests it's not as trivial as I'd anticipated.

Using iOS 13 and Swift 5, I have an array of Doubles representing time intervals in seconds. I want to generate a series of sounds (clicks?) separated by each of these intervals in sequence.

I found a couple of relatively old threads about metronomes, etc.:

that suggest that using timers isn't that accurate. These threads are a decade old and often use a repeated interval versus reading from an array.

Where should I be looking? Timer? Date? DispatchQueue.main.asyncAfter??