How to make the NSOperationQueue serial? [closed] How to make the NSOperationQueue serial? [closed] ios ios

How to make the NSOperationQueue serial? [closed]


If you want a serial queue, you are right setting maxConcurrentOperation to one. You can also use [NSOperationQueue mainQueue] instead of creating a new queue, and so queue operations on the main thread. But that is only useful if very short operations are added and so the user interface is not blocked. And on the other hand you have not to worry about threads n synch.

You can add operations to any queue with addOperations:waitUntilFinished:YES or sending the message waitUntilAllOperationsAreFinished every time you add an operation. That way you are serializing operations instead of defining the queue as serial.