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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.