【问题标题】:How can I get the "internet time" on iOS? [duplicate]如何在 iOS 上获取“互联网时间”? [复制]
【发布时间】:2015-01-25 03:10:48
【问题描述】:

所以,我正在开发一个基于时间的应用程序,但使用 NSDate,用户可以通过更改设备的系统时间轻松破解应用程序。所以我可能想使用更好的方法来检索时间。

我该怎么做?有没有一种简单的方法可以从互联网上检索时间?

【问题讨论】:

    标签: ios objective-c time nsdate clock


    【解决方案1】:

    查看此 Google 图书馆:https://github.com/jbenet/ios-ntp

    库设置完成后,您可以通过以下行来使用它:

    [NSDate networkDate];
    

    这里也回答了类似的问题:Get Date and Time from Apple Server

    【讨论】:

    • 我发现“ios-ntp”在应用程序从前台移动到后台或反之亦然的情况下不可靠,在这些情况下它给了我设备时间。如果我的假设是错误的,请帮忙。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-22
    • 1970-01-01
    • 2012-10-15
    • 2016-08-28
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    相关资源
    最近更新 更多