如何在应用程序运行之间本地检测用户的iPhone时钟进度? [英] How can I locally detect iPhone clock advancement by a user between app runs?

查看:153
本文介绍了如何在应用程序运行之间本地检测用户的iPhone时钟进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

休闲游戏的一个常见用途是人为地推进系统时钟以在游戏中领先。如何在iOS设备上的应用程序检测到这样的用户时钟进度?

A common exploit in casual games is to artificially advance the system clock to jump ahead in gameplay. How can such user clock advancement be detected by an app on an iOS device?


  • 不得涉及网络通信

  • 当时钟提前时,不得假设app已打开(正在运行或暂停)

  • 必须检测时钟提升,检测时钟回滚是不够的

理想情况下,该解决方案对于重新启动非常强大,但这不是必需的。

Ideally, the solution would be robust against reboots, but that is not a requirement.

推荐答案

CACurrentMediaTime& mach_absolute_time

CACurrentMediaTime & mach_absolute_time

看看这个问题:

iOS:如何测量通过时间,与时钟和时区变化无关?

计算Cocoa中两个时间点之间的秒数,即使系统时钟已经中途改变了

CACurrentMediaTime使用mach_absolute_time:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreAnimation_functions/Reference/reference.html

CACurrentMediaTime uses mach_absolute_time: 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

Here you have an example on how to use CACurrentMediaTime: 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:// shiftedbits。 org / 2008/10/01 / mach_absolute_time-on-the-iphone /

Here you have a more information on mach_absolute_time: http://developer.apple.com/library/mac/#qa/qa1398/_index.html http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/

这篇关于如何在应用程序运行之间本地检测用户的iPhone时钟进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆