i am using the following method in a uiview subclass:
[self performSelector:@selector(timeout) withObject:nil afterDelay:20];
The method is called after 20 seconds as expected. In another method i try to cancel the perform request using the following code:
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(timeout) object:nil];
i've also tried
[NSRunLoop cancelPreviousPerformRequestsWithTarget:self selector:@selector(timeout) object:nil];
both messages don't bring the expected result an the timeout method is still called. can anybody explain me what i am doing wrong and how to do it the right way ?
cheers from austria martin
Two points
1. Are both self
same object??
2. Is [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(timeout) object:nil];
performed on same thread on which you called [self performSelector:@selector(timeout) withObject:nil afterDelay:20];
?
Check these two problems.