I have a recursive call to perform some logged movements from user. While the animation is performed using the following recursive call, if user presses the back button to pop the viewcontroller out of the stack, somehow the animation doesn’t stop and I can see the log entries (representing different log movements) on the console.
-(void)replayNextLog {
if ((replayLogIndex < [lastTurnGameLogList count]-1) && (!skipReplayButtonWasPressed)) {
float delayToNextReplay;
//the replayLogIndex ends with count-1 because the last one is empty due to the last empty line
NSDictionary *logEntryDict = [lastTurnGameLogList objectAtIndex:replayLogIndex];
for (id key in logEntryDict) {
if ([key isEqualToString:kGuessMoveTypeLetterButton]) {
} else if ([key isEqualToString:kGuessMoveTypeRevealHint]) {
} else if ([key isEqualToString:kGuessMoveTypeReset]) {
} else if ([key isEqualToString:kGuessMoveTypePass]) {
} else if ([key isEqualToString:kGuessMoveTypeShuffle]) {
}
}
replayLogIndex++;
// Recursive call
[self performSelector:@selector(replayNextLog) withObject:nil afterDelay:delayToNextReplay];
}
}
Could it be because of any leaks in the view controller? For your convenience, let me tell you that I am not reaching the dealloc method of the VC.
Thanks in advance.
Regards,
Obaid
You will need to control the animation/recursion, possibly using an instance variable, and start it from within the
viewDidAppearmethod and stop it from theviewDidDisappearmethod. The view controller isn’t necessarily destroyed just because it’s popped from the navigation controller.