Skip to content

Instantly share code, notes, and snippets.

@norio-nomura
Created February 12, 2009 23:29
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 norio-nomura/62940 to your computer and use it in GitHub Desktop.
Save norio-nomura/62940 to your computer and use it in GitHub Desktop.
wait NSURLConnection's finish
NSString *connectionRunLoopMode = @"connectionRunLoopMode";
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:urlRequest delegate:urlConnectionDelegate startImmediately:NO];
NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop];
[connection unscheduleFromRunLoop:currentRunLoop forMode:NSDefaultRunLoopMode];
[connection scheduleInRunLoop:currentRunLoop forMode:connectionRunLoopMode];
[connection start];
while ([currentRunLoop runMode:connectionRunLoopMode beforeDate:[NSDate distantFuture]]);
@mraavi
Copy link

mraavi commented Oct 10, 2014

Thank you. Saved my time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment