0

I am currently using CADisplayLink to perform some specific deceleration animation. I set the frameInterval to 1. I have seen some open source projects just use 1/60 second as time delta between frame updates. I found there is also a timestamp method available, however it is in mach format. Which one should I use, can I assume all the iPhone refresh rate is 60hz, and hence safe to use 1/60? If I use timestamp method, how should I convert it to seconds?

Many thanks in advance.

crab oz
  • 635
  • 7
  • 16

1 Answers1

2

Using 1/60 s as time delta is dangerous because you never know if future devices or external displays will use that refresh rate. So if you want to be future-proof, you should rather use a timestamp-based solution. You can use the Unix epoch timestamp and compute the interval between 2 target calls:

UInt64(NSDate().timeIntervalSince1970 * 1000.0)

You can also use the CADisplayLink timestamp, which is already in seconds: https://developer.apple.com/reference/quartzcore/cadisplaylink/1621257-timestamp

Beg2k1
  • 61
  • 5