休闲游戏中的一个常见漏洞是人为地提前系统时钟以在游戏中向前跳跃。 iOS 设备上的应用程序如何检测此类用户时钟提前?
- 不得涉及网络通信
- 当时钟提前时,不得假设应用程序已打开(运行或暂停)
- 必须检测时钟前进,仅检测时钟回滚是不够的
理想情况下,该解决方案对于重新启动具有鲁棒性,但这不是必需的。
CACurrentMediaTime 和 mach_absolute_time
看看这个问题:
iOS:如何测量经过的时间,独立于时钟和时区的变化? https://stackoverflow.com/questions/4008503/ios-how-to-measure-passed-time-independent-of-clock-and-time-zone-changes
在 Cocoa 中计算两个时间点之间的秒数,即使系统时钟中途发生了变化 https://stackoverflow.com/questions/1627764/calculating-number-of-seconds-between-two-points-in-time-in-cocoa-even-when-sys
CACurrentMediaTime 使用 mach_absolute_time:http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreAnimation_functions/Reference/reference.html http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreAnimation_functions/Reference/reference.html
这里有一个关于如何使用 CACurrentMediaTime 的示例:http://www.informit.com/blogs/blog.aspx?b=02b4e309-308c-468a-bab1-cebb1404be6a http://www.informit.com/blogs/blog.aspx?b=02b4e309-308c-468a-bab1-cebb1404be6a
这里有关于 mach_absolute_time 的更多信息:http://developer.apple.com/library/mac/#qa/qa1398/_index.html http://developer.apple.com/library/mac/#qa/qa1398/_index.html
http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/ http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)