title: Method to download using generics asks for more context
body: <p>I wrote a method using generics in order to make it reusable to any kind of download. It downloads json arrays and returns a generic object or an error.
  This is my class to download json arrays from server: </p>
  
  <pre><code>import Foundation
  enum Result&lt;T&gt; {
      case success(T)
      case failure(Error)
  }
  class LTLNetworkClient: NSObject {
  
      fileprivate var session : URLSession
      fileprivate var objectTask : URLSessionDataTask?
  
      override init() {
          let config = URLSessionConfiguration.ephemeral
          config.timeoutIntervalForResource = 5
          config.timeoutIntervalForRequest = 5
          self.session = URLSession.init(configuration: config)
      }
  
      /**
      Download asynchronously json object from Server and returns it into generic data models
      */
      func getData&lt;K: Codable&gt;(request: URLRequest, completion: @escaping (Result&lt;[K]&gt;) -&gt; Void) {
          let sessionDataTask = URLSession.shared.dataTask(with: request) { (responseData, response, responseError) in
              if let jsonData = responseData {
                  let decoder = JSONDecoder()
                  do {
                      let response = try decoder.decode([K].self, from: jsonData)
                      let result: Result&lt;[K]&gt; = Result.success(response)
                      completion(result)
                  } catch {
                      completion(.failure(error))
                  }
              } else if let error = responseError {
                  completion(.failure(error))
              } else {
                  let error = NSError(domain: "Cannot form jsonData with Response Data", code: 501, userInfo: nil)
                  completion(.failure(error))
              }
          }
          sessionDataTask.resume()
      }
  }
  </code></pre>
  
  <p>And this is how I call the method and the error I get: </p>
  
  <p><a href="https://i.stack.imgur.com/jHO19.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jHO19.png" alt="enter image description here"></a></p>
  
  <p>Does anyone knows how to fix it and why this error appears?
  Many thx in advance</p>