NSTimer() interval resolution

According to https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/

interval resolution of the timer is 50-100ms at best. I would like to duplicate the iOS 9.x default clock app's stopwatch resolution of 10ms. How can that be achieved? Thanks.

Replies

Use CADisplayLink to synchronize drawing with the refresh rate of the display.


https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CADisplayLink_ClassRef/index.html

Thanks, *****. I will look into this.

To follow up from *****’s suggestion, it’s important to separate your internal representation of time from your display of that time. Internally your timer should track times at high resolution. NSTimeInterval has plenty of precision to do that. OTOH, if you’re updating your UI to reflect that time, there’s no point doing that faster than the display refresh rate (typically 16 ms) and CADisplayLink is ideal for that.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi, I have a question, is the NSTimer monotonic timer or wall clock?

That’s a surprisingly complex question, and quite different from the original question on this thread. Please start a new thread for it and I’ll reply there.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hello, I have already start a new thread for this question.
The New Thread is:
https://forums.developer.apple.com/message/322695#322695


thx.