I started using NSOperationQueue in my own work recently to manage background network requests. NSOperation deals with most of the template code needed for asynchronously executing tasks (such as network operations) in threads in the background (or foreground, if necessary for user interface updates).
It also allows you to set dependencies between queues; for example, I use two queues in my application:
The first graph is loading images with a maximum concurrency of 2 at a time, in the background. Each image download has a corresponding completion handler (like NSBlockOperation ), which depends on the completion of the image loading. These operations are hosted on [NSOperationQueue mainQueue] , which runs in the main thread, which allows them to update the interface (in particular, the corresponding UIImageView ).
Please note that NSOperation and NSOperationQueue not only for network queries, but also for any operation that can be divided into atomic tasks and scheduled at the same time.
Here are Apple's intro docs on this topic.
source share