Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should use implement the <code>NSConnectionDataDelegate</code> protocol and use the <code>NSConnection</code> class. I believe that by the time <code>-(void) connectionDidFinishLoading:(NSURLConnection *)connection</code> is called, the page has finished loading completely.</p> <pre><code>-(void) requestPage { NSString *urlString = @"http://the.page.you.want.com"; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowed timeoutInterval:20.0f]; responseData = [[NSMutableData alloc] init]; connection = [[NSURLConnection connectionWithRequest:request delegate:self] retain]; delegate = target; } -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { if ([response isKindOfClass:[NSHTTPURLResponse class]]) { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response; //If you need the response, you can use it here } } -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } -(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [responseData release]; [connection release]; } -(void) connectionDidFinishLoading:(NSURLConnection *)connection { if (connection == adCheckConnection) { NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; //You've got all the data now //Do something with your response string [responseString release]; } [responseData release]; [connection release]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload