Creating the manager

Now let's implement that HTTP request manager:

  1. Create a new Swift file and name it HTTPRequestManager.swift.
  2. Under the import statement, create the HTTPRequestManager class by adding the following code:
class HTTPRequestManager {     static let sharedInstance = HTTPRequestManager ()     let session: URLSession     let sessionDelegate: HTTPRequestDelegate     private  init()     {         let configuration =                   URLSessionConfiguration.background(withIdentifier:                  "downloadConfig")         configuration.httpAdditionalHeaders                          = ["Accept": "application/pdf"]         sessionDelegate = HTTPRequestDelegate()         session = URLSession(configuration: configuration,                                  delegate: sessionDelegate,                                  delegateQueue: nil)     } } 

Once again, the compiler is puzzled by the stuff ...

Get Mastering macOS Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.