Question

We have known too many advantages when replacing NSOperation with GCD like: 1. elegance and less codes 2. higher performance since it's low level API

So, after GCD comes out, I never use NSOperation again in my daily work.

However, is there any situation/example that NSOperation is preferred to be used rather than GCD?

Thanks

Was it helpful?

Solution

'NSOperation' gives you possibility to specify maximal number of concurreny request using setMaxConcurrentOperationCount: method which is often really nice thing to have.

Also NSOperation let you to specify pretty complex dependencies between some operations using addDependency: method. You can tell that some execution of some operation should start only when some others operations finished. Of course you can achieve the same efect using GCD but this will fast become pretty overkill as with many dependencies nested blocks will be not the cleanest solution.

When it comes to description of GDC and NSOperationsQueue's there isthis article. I found it to be really helpfulf.

//EDIT Also, it seems NSOperation's are more object oriented approach which give you possibility to specify logic of some request to be fully isolated into NSOperation's subclass.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top