If I have a view with a performSelector set to fire after a delay:
[self performSelector:@selector(generateBall) withObject:NULL afterDelay:1.5];
...but I removeFromSuperview that view before the selector fires (for example, due to user interaction), then my app crashes.
Is there a way to kill the delayed selector in the dealloc method for that view?
EDIT:
I've tried both:
[[NSRunLoop mainRunLoop] cancelPerformSelector:theBall target:self argument:nil];
and
[[NSRunLoop currentRunLoop] cancelPerformSelector:theBall target:self argument:nil];
and while both work (allowing me to load a new view), loading the previous view ends up giving me a gray screen.
I haven't been able to find any tutorials or other information about cancelPerformSelector other than those Apple docs that were listed, and the documentation on threads and run loops seem to be very convoluted (mostly because they don't list working code samples, which would make it easier for me to step through and understand what was going on).