If I have a view with performSelector set after a delay:
[self performSelector:@selector(generateBall) withObject:NULL afterDelay:1.5];
... but I delete FromSuperview that the view before the selector fires (for example, due to user interaction), then my application crashes.
Is there a way to kill the delay selector in the dealloc method for this view?
EDIT:
I tried both:
[[NSRunLoop mainRunLoop] cancelPerformSelector:theBall target:self argument:nil];
and
[[NSRunLoop currentRunLoop] cancelPerformSelector:theBall target:self argument:nil];
and while both work (letting me load a new view), loading the previous view ends up giving me a gray screen.
I was not able to find any tutorials or other information on cancelPerformSelector other than the Apple documents that were indicated, and the documentation on threads and startup loops seems to be very confusing (mainly because they do not display the working code samples that would make it easier for me to go through and understand what is happening).
iphone selector
Jeffrey berthiaume
source share