How to check the correct current time if user sets “Set Automatically” off

我们两清 提交于 2019-12-30 11:34:07

问题


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

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;

Is there any way to archive this behavior in ios.


回答1:


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.



来源:https://stackoverflow.com/questions/33752318/how-to-check-the-correct-current-time-if-user-sets-set-automatically-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!