从iPhone应用程序中了解设备中的日期和时间设置 [英] To know date and time settings in device from an iPhone application

查看:103
本文介绍了从iPhone应用程序中了解设备中的日期和时间设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道用户是否已将设备设置为自动设置iPhone中的Settings.app中的日期和时间。我需要这些信息,因为我想让用户在应用程序中访问一些信息一天,他只能在第二天再次访问。但智能用户可以更改日期并访问信息。所以我想检查他们是否为设备自动设置日期/时间。

I want to know whether the user has set their device to automatically set the date and time in the Settings.app in iPhone. I need this information because I want to make user to access some informations in the app only for a day, which he can access again only on second day. But an smart user can change the date and access the information. So I want to check whether they set the date/time automatically for the device or not.

有没有办法这样做。如果存在,请建议任何其他替代方式。
提前感谢

Is there any way for doing so. Please suggest any other alternate way if exist. Thanks in advance.

推荐答案

我不认为有一种方法来检测用户对自动更新日期时间设置。要确定从给定点的时间长度,您有几个选项,其中没有一个是绝对的或没有任何错误。

I don't believe there exists a way to detect the user's preference regarding the automatic update of the date time settings. To determine the length of time from a given point, you have a few options none of which are absolute or without any error.


  1. 使用NSDate ,您可以通过手动更改设备上的日期来规避您已经知道的情况。

  2. 使用时间服务器。通过查询时间服务器,您可以获得独立的日期时间值。存储该值并与之进行比较,以确定适当的时间量是否过去。这个缺点当然是需要互联网连接到功能属性。

  3. 使用系统时钟值或一系列值粗略计算经过的时间。 C code> CACurrentMediaTime 或 mach_absolute_time()之类的功能可以提供与之进行比较的计数。您可以使用这些值并增加它们,直到达到指定的持续时间以重置第二天检查的标志。

  1. Use NSDate, which you already know can be circumvented by manually changing the date on the device.
  2. Use a time server. By querying a time server you can get an independent date time value. Store that value and compare against it to determine if the right amount of time has passed. The drawback of course, is this requires an internet connection to function property.
  3. Use a system clock value or series of values to roughly calculate the time elapsed. A functions like CACurrentMediaTime or mach_absolute_time() can provide a count to compare against. You can take the values and increment them until you have reached a specified duration to reset a flag for your second day check.

单独的选择将提供一个理想的解决方案,但通过组合这些方法,您可以在允许的时间内获得用户正在访问信息的可接受水平的保证。

None of the options alone will provide an ideal solution, but by combining the approaches, you might achieve an acceptable level of assurance the user is accessing the information only during the time allowed.

这篇关于从iPhone应用程序中了解设备中的日期和时间设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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