I'm writing an app in which it would be useful to have very precise data about when a user taps a UIView
.
The the UIEvent
passed to touchesBegan:
only has timing data in seconds, which is not nearly precise enough.
So, logically, the next step seems to be to record the time that touchesBegan:
is called using mach_absolute_time()
or something similar. This approach works well most of the time, but if the system is doing some really intense work (especially on the main thread doing UI work), it looks like touchesBegan
gets pushed back in the loop a bit -- it still fires, but late.
I'm hoping that there may be a lower-level solution that I can use at some point in the signal chain to grab more precise data (at least on the order of milliseconds instead of seconds).
Of course, I'll also try to keep my UI thread running as efficiently as possible to avoid those delays, but especially on older devices, it seems like those small hiccups in timing are somewhat unavoidable.
UIEvent
's timestamp is an NSTimeInterval, which is a floating-point type for which whole numbers correspond to whole seconds... but the fractional part includes sub-millisecond precision. Are you sure it's not precise enough for you?