Home  >  Q&A  >  body text

objecive-c - iOS获取当前app运行时长

我们的应用有倒计时,但是如果应用在后台2个小时后在打开,应用没有被kill,这时我希望知道应用已经2小时了,想刷新倒计时间啊。

1、系统有获取应用运行时间的方法吗?
2、自己记录时间,应用用什么方法?最佳实践?

PHP中文网PHP中文网2741 days ago322

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 09:23:58

    1. Record the current time when entering the background (applicationDidEnterBackground:)

    2. Record the current time when entering the front desk (applicationWillEnterForeground:)

    3. Just subtract the two times

    reply
    0
  • Cancelreply