Aug 4, 2008

(Objective-C) Add a wait time in NSUrlConnection

Here is a regular connection object

NSURLConnection *askConnection = [[NSURLConnection alloc] initWithRequest:askRequest delegate:self];
[askConnection start];

this connection in the main thread, it has a default time to wait for http response and received data. But if we put this connection in a separate thread, it won't wait for response, in this case we should add the follow line to wait the connection response

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];

No comments: