Now let's implement that HTTP request manager:
- Create a new Swift file and name it HTTPRequestManager.swift.
- 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 ...