I was designing an app that uses NSURLSession and thinking about putting it in a different thread with Grand Central Dispatch, but if NSURLSession automatically does that in the background, I wouldn't have to use GCD then, correct?
So in other words, does NSURLSession automatically use Grand Central Dispatch in the background, so we don't have to worry about it?
Best How To :
NSURLSession does it's work in a background thread. The download ALWAYS takes place on a background thread.
You can control whether it's completion methods are executed on a background thread or not by the queue you pass in in the delegateQueue parameter to the init method. If you pass in nil, it creates a (background thread) serial operation queue where your completion methods are called. If you pass in
NSOperationQueue.mainQueue() then your completion delegate methods will be invoked on the main thread and you won't have to UI calls in dispatch_async() calls to the main thread.