I have very simple method that is being called by performSelector:withObject:afterDelay: however no matter what value I assign to afterDelay, the method is always fired after a 10 second delay. The method calls a URLRequest that when complete, invokes another request (not sure this has implications or not).
I have:
-(void)connectionDidFinishLoading:(NSURLConnection*)connection {
[self performSelector:@selector(poll) withObject:nil afterDelay: 1];
}
.....
-(void)poll
{
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
....
NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
.....
}
No matter what value I assign to afterDelay, the method is always invoked after 10 seconds. Any ideas as to what might cause this?
Is your NSURLConnectionDelegate getting messages on a thread different from the main thread? If so then post your message to the mainThread instead:
then
PS: you can do this more easily with dispatch_after() but you didn’t mention blocks so didn’t go there.
PS: try adding this to all your delegate messages:
If that does not crash your app, then something is blocking our main runLoop – the one on your main thread – so you are probably waiting on something somewhere. In this case your UI would be totally unresponsive.