Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>NSURLSession</code> works at an "upper" level, and is made to be more simple for the developer than using <code>NSURLConnection</code>.<br> I made some tests and I think that there is no possibility to control the runloop and the mode of <code>NSURLSession</code>, because they seems to be managed by an external daemon and not by your App (I tested only with <code>NSURLSessionDownloadTask</code>).<br> Do this simple test: </p> <ol> <li>download and execute <a href="https://github.com/lombax85/iOS7Downloader" rel="nofollow">this Github project</a> </li> <li>start a download</li> <li>open the "downloads" controller to see the state of your download</li> <li>pause the app </li> <li>wait a moment</li> <li>unpause the app</li> </ol> <p>you will see that the download has been continued while your app was paused, so when you start a <code>NSURLSession</code> the control is passed to the system, outside your app: it means that the main part of the work doesn't take place in an internal runLoop.</p> <p>The only thing you have control on, is the serial queue on which the delegate calls are dispatched (passed back to your application). The delegate calls are queued for execution (on the main or on a background thread, you can choose it), since <code>NSOperationQueue</code> use Grand Central Dispatch to queue the calls, I'm not sure about the runloop mode used for this, but I think this is a good starting point to continue your researches.</p> <p>EDIT: If I remember correctly, dispatch calls made on background threads are made on threads where a runloop is not running. In fact, if you add this line</p> <pre><code>NSLog(@"%@", [[NSRunLoop currentRunLoop] currentMode]); </code></pre> <p>on one of the delegate methods of the <code>FLDownloader</code> class in the previous project, you will see that there is no run mode (nil), this happens when the runloop is not running. </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