NSTimerinstances must always be scheduled at runtime for proper operation. If you do this from the main thread, you can just use it scheduleTimerWithTimeInterval, and it will be automatically added to the main loop of the loop for you, and a manual method call is NSRunLoop addTimernot required. But you can create a timer and add it yourself if you want. scheduleTimerWithTimeInterval- A convenience method that just does it for you.
If you create a timer from a background thread that does not have its own run loop (and by default when using background dispatch queues or operation queues, the thread that is running will not have its own loop run), you must manually add the timer to the run loop. Typically, people simply add a timer to the main startup loop.
, , , , GCD, . . fooobar.com/questions/958131/... Objective-C. . fooobar.com/questions/83124/... Swift.
, , scheduledTimerWithTimeInterval, , .