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

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

问题描述

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

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

有什么方法可以访问自动设置"设置状态,以便我提示用户将其打开. 或者 我可以遵循的另一种方法是我可以从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天全站免登陆