NSTimer is pausing a while an then again it is starting when UIGesture action performed.
I am developing an iOS application where I have to trigger the NSTimer repeatedly for every 0.5 seconds and based on that timer I’m moving a song progress bar. And also handling touch events when user touching on some images which I kept on the same view. I am seeing when user touches the images, the timer for moving the progress bar is stopping a little while and continues again.
Are there any problem that we can’t handle timer and touch events at the same time in the same view?
My code for timer
myTimer = [NSTimer scheduledTimerWithTimeInterval:timeinterval target:self selector:@selector(updatplayer:) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:myTimer forMode:NSRunLoopCommonModes];
This is a common issue with NSTimer. While you can play with run loop modes to improve things, a nicer solution is to switch to GCD timers. See RNTimer for an example. See the docs on dispatch_source_create for more information.