Is NSTimer thread safe?

I have a repeat timer in 1/4 second intervals. I initialize it as follows:

[NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(toggleCams) userInfo:nil repeats:YES]; 

Does this happen synchronously? In other words, am I sure that another method in the same class will not be called at the same time as the call? Do cameras get called?

+6
source share
1 answer

NSTimers actually just fire events periodically into the spanning NSRunLoop that each thread has (or should have). So, if you have a child (or background) process running in another thread, NSTimers will start this NSRunLoop thread instead of the main NSRunLoop application.

+18
source

Source: https://habr.com/ru/post/903973/


All Articles