You "call a method again and again after a time delay" you`d better use
timer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(someMethod)
userInfo:nil repeats:YES];
and in viewllDidDisappear , use [timer invalidate]
to stop it.
your "somemethod " write like this?
- (void)somemethod
{
//your code
[self performSelector:@selector(someMethod) withObject:nil afterDelay:1];
}
maybe you should add a test button , it calls [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(someMethod) object:nil];
when it clicked. to check whether it works.
you can code like to solve the problem.
- (void)somemethod {
if (needStop) {
return;
} //your code [self performSelector:@selector(someMethod) withObject:nil
afterDelay:1];
}
in the viewDidDisappear set the needStop = YES;