Everything was OK, until yesterday when my app started to behave weirdly. It works OK on simulator but on iPhone4 it performs one additional cycle even after stopping it. Here's my initializer that creates a new CADisplayLink timer or resumes existing one:
-(void)initializeTimer{
if (self.theTimer == nil) {
self.theTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(gameLoop)];
self.theTimer.frameInterval = 2;
[self.theTimer addToRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode];
} else {
self.theTimer.paused = NO;
}
}
I need to stop and resume the timer quite frequently, so I'm stopping the timer with pause property:
self.theTimer.paused = YES;
Then I'm calling initializer that resumes it (self.theTimer.pause = NO). As said, it performs one additional call to selector method. Very strange, I had this app working with no CADisplayLink problems more than a month. I didn't do any updates to iPhone recently. In addition, systems sounds stopped to play at the same moment but AVAudioPlayer objects still work. As I said both timer and sounds works perfectly on simulator but I want to find out what causes a problem on iPhone. All stuff is done with pure UIKit. Any ideas where to start?