NSURLConnection
with delegate calls is "old school" way of receiving data from remote server. Also it's not really comfortable to use with few NSURLConnection instances in a single class (UIViewController
or what not). Now it's better to usesendAsynchronousRequest..
method with completion handler. You can also define on which operation queue (main for UI, or other, background one) the completion handler will be run.- GCD is good for different tasks, not only fetching remote resources with
initWithContentsOfURL:
methods. You can also control what type of queues will receive your blocks (concurrent, serial ,etc.) performSelectorInBackground:
is also "old school" way of performing a method in background thread. If you weren't using ARC, you'd need to setup separate autorelease pool to avoid memory leaks. It also has a limitation of not allowing to accept arbitrary number of parameters to given selector. In this case it's recommended to usedispatch_async
.
There are also NSOperationQueue
with NSOperation
and its subclasses (NSInvocationOperation
& NSBlockOperation
), where you can run tasks in the background as well as get notifications on main thread about finished tasks. IMHO They are more flexible than GCD in a way that you can create your own subclasses of operations as well as define dependencies between them.