gpt4 book ai didi

iphone - NSTimer 和非事件/ sleep 状态

转载 作者:搜寻专家 更新时间:2023-10-30 20:21:00 24 4
gpt4 key购买 nike

我在 iPhone: Detecting user inactivity/idle time since last screen touch 中找到了答案但是当设备进入非事件/ sleep 状态时会发生什么?计时器停止计时了吗?

最佳答案

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nstimer_Class/Reference/NSTimer.html

A timer is not a real-time mechanism; it fires only when one of the run loop modes to which the timer has been added is running and able to check if the timer’s firing time has passed. Because of the various input sources a typical run loop manages, the effective resolution of the time interval for a timer is limited to on the order of 50-100 milliseconds. If a timer’s firing time occurs during a long callout or while the run loop is in a mode that is not monitoring the timer, the timer does not fire until the next time the run loop checks the timer. Therefore, the actual time at which the timer fires potentially can be a significant period of time after the scheduled firing time.

因此,当您的应用进入非事件状态时 - 计时器将停止触发。当您的应用返回事件状态时 - 计时器将再次启动。

关于iphone - NSTimer 和非事件/ sleep 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11108115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com