NSTimer and long task
I am wondering what happen if my NSTimer fires every 1 second and my function takes 2 seconds to per开发者_StackOverflowform the task.
Thanks for your answer.
Thierry
Is your function blocking? According to the documentation,
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. If a timer’s firing time occurs while the run loop is in a mode that is not monitoring the timer or during a long callout, 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.
Therefore, your timer will not fire during the task if it is blocking.
精彩评论