Leveraging DispatchGroups
In the previous 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/PacktPublishing/Swift-Cookbook-Third-Edition/tree/main/Chapter%206 and choose the PhotobookCreator_DispatchGroups
folder.
Open the project in Xcode and navigate to the PhotoCollectionViewController.swift
file.
How to do it...
In the last recipe, we saw how dispatch queues operate on a FIFO policy. GCD will execute a block from the top of the queue and remove it from the queue when it has finished executing. The number of blocks that GCD will allow to execute at the...