I'm trying to use downloadTaskWithURL() but upgrading it to the latest version: downloadTask and I'm trying to run this code snippet but it won't compile.
Here's what I have done so far:
let downloadTask: URLSessionDownloadTask = URLSession.shared.downloadTask(with url: endpointURL, completionHandler: { (url: URL!, response: URLResponse!, error: Error!)
if (error == nil) {
//some code
}
})
downloadTask.resume()
What am I doing wrong?