The current implementation looks a little like this:
- At the beginning of the game, save the time the game started using two timers - the "user modifiable clock" ( [NSDate timeIntervalSinceReferenceDate] ) and the "system clock" (mach_absolute_time or CACurrentMediaTime). These two timers will have different values but should grow at the same rate.
- Every frame, diff the current values of the respective timers against the times we saved.
- If the two differences are too far apart (within some margin of error), we know the clock has been tampered with, since the only way that should be possible is if the user changed their clock.
This doesn't quite work out, though. On some devices, mach_absolute_time grows faster than [NSDate timeIntervalSinceReferenceDate]. This isn't behavior I'd expect - they should both be determining, well, time, but I guess one of these timers is not terribly accurate.
Has anyone encountered this? It's a pretty niche problem.