Skip to content

Instantly share code, notes, and snippets.

@vickeryj
Created February 24, 2009 20:26
Show Gist options
  • Save vickeryj/69762 to your computer and use it in GitHub Desktop.
Save vickeryj/69762 to your computer and use it in GitHub Desktop.
ConnectionDelegate *connectionDelegate = [[[ConnectionDelegate alloc] init] autorelease];
NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:request delegate:connectionDelegate startImmediately:NO] autorelease];
connectionDelegate.connection = connection;
NSRunLoop* runLoop = [NSRunLoop mainRunLoop];
[connection unscheduleFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[connection scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode];
[connection start];
while (![connectionDelegate isDone]) {
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:.3]];
}
Response *resp = [Response responseFrom:(NSHTTPURLResponse *)connectionDelegate.response
withBody:connectionDelegate.data
andError:connectionDelegate.error];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment