如果用户设置“自动设置”,如何检查正确的当前时间离 [英] How to check the correct current time if user sets "Set Automatically" off

查看:73
本文介绍了如果用户设置“自动设置”,如何检查正确的当前时间离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户将自动设置关闭,我必须检查正确的当前时间。

I have to check the correct current time if user sets "Set Automatically" off.

有没有办法访问自动设置设置状态的状态所以我提示用户打开它。
OR
我可以遵循的另一种方法我可以从GPS(位置)获取时间,但是如果用户选择
自动设置,则下面的代码总是给出本地时间。

Is there any way to access the status of "Set Automatically" setting status so that I cam prompt user to turn it on. OR Another approach I can follow I can fetch the time from GPS(location) but the below code always gives the local time in case of user selects "Set Automatically" off.

CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0];
NSDate* now = location.timestamp;

有没有办法在ios中存档此行为。

Is there any way to archive this behavior in ios.

推荐答案

如果您不能依赖本地时钟,则需要使用外部源。 (可能)有几个基于NTP的库。例如:ios-ntp,目前可以在这里找到。

If you can't rely on the local clock, you need to use an external source. There are (probably) several NTP-based libraries for this. For example: ios-ntp, which can currently be found here.

这篇关于如果用户设置“自动设置”,如何检查正确的当前时间离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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