Concurrent queues and dispatch groups
In the last recipe, we looked into using a private serial queue to keep our app responsive by moving long-running operations off the main queue. In this recipe, we will break our operations down into smaller, independent blocks and place them on a concurrent queue.
Getting ready
We are going to build on the app we improved in the last recipe, which is an app that will produce a PDF photo book from a collection of photos. You can get the code for this app at https://github.com/SwiftProgrammingCookbook/PhotobookCreator and choose the branch start-dispatch-groups
, or you can use git
:
git clone https://github.com/SwiftProgrammingCookbook/PhotobookCreator.git
git checkout start-dispatch-groups
Open the project in XCode, and navigate to the PhotoCollectionViewController.swift
file.
How to do it...
We saw in the last recipe how Dispatch Queues operate on a first in first out policy; Grand Central Dispatch (GCD) will execute a block from the top of the queue, and...