ios - How to determine the age of CMDeviceMotion in seconds -
i want able turn device motion updates on , off during game. after turn them off , again, .devicemotion property of cmmotionmanager returns last know devicemotion short while (around 0.5 seconds, until can calculate fresh value, guess).
so, want able test age of cmdevicemotion objects get, , ignore them if they're older few seconds.
calculating cacurrentmediatime() - devicemotion.timestamp seems give me accurate results.. i'm worried might break in future device or ios version. device motion timestamps guaranteed remain comparable cacurrentmediatime() in future? there better way calculate age of cmdevicemotion timestamps?
from apple's documentation:
a cftimeinterval derived calling mach_absolute_time() , converting result seconds.
the time stamp amount of time in seconds since phone booted.
i had same problem , needed keep history of events. solved setting updateinterval pretty low values e.g. 0.5. core motion doesn't need reinitialise sensors , slow down energy consumption.
Comments
Post a Comment