Note that there are some explanatory texts on larger screens.

plurals
  1. PONSURLConnection doesn't receive data when creating many downloading objects in iOS5
    text
    copied!<p>I have been searching for this problem on the SOF for several days and I still have not found the solution (say the same problem) yet.</p> <p>I'm making and app that downloads 5 images simultaneously in an URL list (each image is on a different server).</p> <p>I have an <code>ImageDownloader</code> class subclasses <code>NSOperation</code> and implements the <code>NSURLConnectionDataDelegate</code>.</p> <p>So that I can add an instance of <code>ImageDownloader</code> to an <code>operationQueue</code> in the <code>ViewController</code> and it will run in a separate thread under the <code>operationQueue</code>. The line that add the downloader to the <code>operationQueue</code> is here:</p> <pre><code>downloader = [[ImageDownloader alloc] init]; [downloader downloadImageWithURL:[controller.URList objectForKey:[NSString stringWithFormat:@"%d",downloadIndex]] queue:queue andTag:downloadIndex + 100]; //my custom initialize downloader.delegate = self; [queue addOperation:downloader]; //use the addOperation method </code></pre> <p>Everything works fine in <strong>iOS6</strong> but messed up in <strong>iOS5</strong> (5.0 on my test device and 5.1 on my SDK), it just doesn't receive any response nor data by performing the methods <code>didReceiveResponse</code> and <code>didReceiveData</code> at all (these 2 methods are not jumped in). </p> <p>After the timeout was exceeded, the runloop jumps into <code>didFailWithError</code> method and the program stalls. </p> <p>As I understand, this means the runloop still runs right?</p> <p>I tried to print out the <code>error</code> and all I got is: <code>The request timed out</code>.</p> <p>When I reduce the number of downloading instances to 2 then it runs, but not with >=3 downloading instances.</p> <p>One more information is that my network connection does limit the number of connection. But it work fine in iOS6, why it just doesn't work on iOS5? </p> <p>I can still load the web in the simulator while the app is downloading.</p> <p>So what kind of problem is this and how can I get over this problem? </p> <p>Thanks in advance.</p> <p>*<strong><em>Update:</em>*</strong> as there are many classes and the problem's not been clearly detected yet, I will share here the whole project. You can download it directly from here: <a href="https://dl.dropboxusercontent.com/u/15628608/Public%20files/DownloadImageByOperation.zip" rel="nofollow">DownloadingImage</a></p>
 

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