I develop an app where a user have few cells in which he can put sounds and then playing the built sequence. There is a metronome, it can tick with sound. Users can set metronome speed, that is the same that to set speed of passing to the next cell. I have realized this mechanism via "timer" with handler, which highlight the current cell and play sounds. Everything works fine. But when I animate some views, my timer stumbles. When animation is finished timer works as expected. How can I resolve this issue?
I have tried to realize timer via NSTimer, dispatch_after, performSelector:afterDelay:, CADisplayLink and dispatch_source_t. In any case I get problems during the animations. I have even tried to realize my own animation via CADisplayLink, where I calculate animated views frames, this didn't help either.
I found a solution, playing with Apple
AVAudioEngineexample HelloMetronome. I understood the main idea. I have to schedule sounds and handle callbacks in the UI. Using any timers for starting playing sounds and updating UI was absolutely wrong.