For the many situations in which we need more control over the download as it progresses, we can adopt a different approach to communicating with the OS, one that gives us much greater flexibility as to how and when we use the downloaded data.
To do this, we must create a class that conforms to at least some of the URLSession delegate protocols (of which there are several, but never fear, we'll start off with just a few). We can add various functions that will be called by the system to inform us that a download has finished, or has been cancelled, or how far through the download we are, for example.
Using a session delegate also allows us to use background download configurations.
There is no SessionDelegate class to subclass; we need to create...