Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Its a <code>synchronous</code> method - i.e. it runs on the <strong>main thread</strong>. Therefore, your application will hang - and it'll wait till the data is downloaded. </p> <p>To prevent it: use the <code>sendAsynchronousRequest</code> method. It'll run this process on a background thread and won't disrupt your application or simply - won't make it <em>hang</em>.</p> <p>Here's how to use <code>sendAsynchronousRequest</code>:</p> <pre><code>NSURL *url = [NSURL URLWithString:@"YOUR_URL_HERE"]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { //the NSData in the completion handler is where your data is downloaded. }]; </code></pre> <hr> <p>Considering all the circumstances, I think that the problem exists due to your delegate declaration. So declare <code>&lt;NSURLConnectionDataDelegate&gt;</code> and the declare an <code>NSMutableData</code> : <code>myData</code> object and an <code>NSURLConnection</code> : <code>urlConnection</code> as properties. Now use this : </p> <pre><code>NSURL *url = [NSURL URLwithString : @"YOUR_URL_HERE"]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; *urlConnection = [NSURLConnection connectionWithRequest:urlRequest delegate:self]; -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [myData setLength:0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [myData appendData:data]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { //You can use the complete downloaded data - NSMutableData here. } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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