There is two-option.
If using a timerWithTimeInterval
use a following like it.
refreshTimer = [NSTimer timerWithTimeInterval:1.0f target:self selector:@selector(timerHandler) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:refreshTimer forMode:NSRunLoopCommonModes];
also mode is two-option. NSDefaultRunLoopMode
vs NSRunLoopCommonModes
more Information. refer a this documentation: RunLoopManagement
If using a scheduledTimerWithTimeInterval
use a following like it.
refreshTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerHandler) userInfo:nil repeats:YES];
scheduled timers are automatically added to the run loop.
more information. refer a this documentation: Timer Programming Topics
In summary
The "timerWithTimeInterval
" you have to remember
to add the timer to the run loop that you want to add on.
The "scheduledTimerWithTimeInterval
" default auto creates a timer that runs in
the current loop.