1) Why should we use NSOperationQueue?
2) What is advantage when we use it?
3) Can we achieve multiple synchronous web operations through NSOperationQueue at the same time?
4) Why do we use NSOperationQueue in lazy-loading of UITableView? Is it not possible to do it without NSOperationQueue?
You should use
NSOperationQueueto achieve concurrency when the unit of work is anNSOperationor one of its subclasses. Or with other API’s that require anNSOperationQueue, e.g. theaddObserverForName:object:queue:usingBlock:method onNSNotificationCenterWhen the unit of work to perform asynchronously can be encapsulated in an
NSOperationobject. Perhaps you’re asking what is the advantage over other asynchronous API’s? There it’s largely, but not entirely, a question of the level of abstraction you need and are comfortable with managing. As one author put it: “Always use the highest-level abstraction available to you, and drop down to lower-level abstractions when measurement shows that they are needed.”Of course. See numerous tutorials online that address this very subject. Like this one by the estimable Marcus Zarra.
For the same reason as you would use any concurrent technique. To make the work faster and/or avoid blocking the UI. In the case you cite, it’s chiefly about not blocking the UI with a long-running task.
Sure it’s possible.
NSThread, GCD, etc.