Is there a clock in iOS that can be used that cannot be changed by the user

后端 未结 6 1094
长发绾君心
长发绾君心 2020-11-30 02:52

I am trying to design a system where real-time events happen and I want to synchronise them to a clock. [NSDate date] would normally be ok but the user could c

6条回答
  •  孤独总比滥情好
    2020-11-30 03:01

    If all you need is a clock to measure events as monotonically increasing, you could just get the current system uptime ala clock_gettime(CLOCK_MONOTONIC). If restarting the device is a problem, just save the last value used and at next launch use the last saved value as an offset. The Problem here may be that if they actually shut the device off, it won't count that time. But if you're worried about the user speeding up time, they can't do that, only slow it down.

提交回复
热议问题