Block structure?


I’m trying to understand the structure of the NSOperationQueue blocks on pp.436-437.

There seem to be three nested blocks here. The outer two of which involve the processingQueue object; the inner one uses the mainQueue. What is the logic for this choice please?

  • Presumably the inner block has to use the mainQueue because it involves the user interface (presenting the images and displaying text).

  • But why have the outer blocks been structured in this way? Why use 3 blocks and not 2, or even 4?

Many thanks in advance!


Right, the inner block is on the main queue for updating the UI.

The outermost block handles enumerating the directory and adding the files it finds as operations on the processing queue. The purpose of this is A) to do the directory enumeration in the background, and B) to do the image loading in the background as well. We could only do the image processing in the background, but if we were dealing with a particularly large directory we would then be blocking the main thread while that directory is enumerated.



Many thanks, Adam - that makes good sense!


This fantastic, really good.