问题
I am using ntp-ios framework downloaded from github in my ipad application to get the GTM time , by using the following code
[NetworkClock sharedNetworkClock]; // // gather up the ntp servers ...
[NSDate networkDate]; // This will give the network date and time regardless of device date
if the device time is wrong , then also i am getting the correct gmt time .
but my problem is , when application goes to background and i changed the device time in settings . then after that if i again make application active by tapping on it , then it's giving wrong gmt time . if i quit the application and launch it again , in that case it's working as expected . please suggest how to fix this .
Thanks in advance . . .
回答1:
Maybe I am not understanding the question correctly but it seems to me that you get the GMT time with the ntp servers and then attempting to get the devices local time settings, that are set in the devices Settings.
These are two different things, if you need to get the correct time when the application comes to foreground I would call those same methods you posted before in the AppDelegates applicationDidEnterForeground ...
If your application is not critically dependent on the correct time I would suggest that you use the local time of the device, I think you could safely assume that most users have the correct time set on their devices ...
来源:https://stackoverflow.com/questions/18845981/ios-ntp-framework-sync-issue