Is NSTimer expected to fire when app is backgrounded?

前端 未结 2 900
说谎
说谎 2020-11-27 18:57

I don\'t understand it at all but NSTimer in my app definitely is running in background. I have a NSLog in method run by the timer and it is loggin

2条回答
  •  情深已故
    2020-11-27 19:35

    NSTimer is going to fire whenever the main runloop is running. Apple makes no promises that I know of to unschedule timers or to prevent the main runloop from running. It's your responsibility to unschedule your timers and release resources when you move to the background. Apple isn't going to do it for you. They may, however, kill you for running when you are not supposed to or using too many seconds.

    There are many holes in the system that will allow an app to run when it isn't authorized to. It would be very expensive for the OS to prevent this. But you cannot rely on it.

提交回复
热议问题