Skip to content

Instantly share code, notes, and snippets.

@sorted-bits
Created October 20, 2011 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorted-bits/1302265 to your computer and use it in GitHub Desktop.
Save sorted-bits/1302265 to your computer and use it in GitHub Desktop.
NSURLConnection in its own thread
NSString* url = @"http://your.url/here";
NSURL* nsurl = [NSURL URLWithString:url];
NSMutableURLRequest* urlReq = [[NSMutableURLRequest alloc] initWithURL:nsurl];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:urlReq delegate:self];
while(!finished) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
finished = TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment