Can't seem to use a custom URLSessionDelegate

So far have this custom API class and I'm wanting to create a custom URL delegate for the tasks that I will be performing with this API, this code below gathered from the Apple Docs -> Apple Docs URL loading/fetching Listing #2 to be exact... keep getting 'Argument type 'API' does not conform to expected type 'URLSessionDelegate''

   var delegate: URLSessionDelegate?

  static var requestObject: URLSession = {
    let configuration = URLSessionConfiguration.ephemeral
    configuration.allowsCellularAccess = true
    configuration.waitsForConnectivity = true
    return URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
   
   
}()
}



protocol URLSessionDelegate{
  var delegate: URLSessionDelegate? {get}
   
}

Not sure why but seems to be maybe error in codebase, as I have tried many tutorials and solutions and no one provides an explicit working version for a custom delegate (not a shared session) that allows for various configurations for URLSessions.

Can't seem to use a custom URLSessionDelegate
 
 
Q