How to download the task using URLSessionDownloadDelegate

By passing days the mobile APP is going more UX and UI friendly . Listening uninterrupted music or videos or browsing infifine scroll in a APP that means APP has to download something from the internet, be it images, data or pdf files or whatever. While your app downloads the required resources, your user has to wait. Now, this isn’t an issue if the resources are small or can be fetched really fast. What if the process isn’t fast enough or the resource is very large (say size in MB in double or even triple digits!)? Your users will have to stare at a blank screen with a probably unresponsive app (depending on how you handled resource loading) which is a deal-breaker and may lead users away from your app. You must do something to assure the users that the required resource is indeed loading and the app isn’t stuck at some deadlock. Show them some progress. Animation, text, percentage labels — whatever goes with your app.

A protocol defining methods that URL session instances call on their delegates to handle task-level events specific to download tasks.

in addition to the methods in this protocol, be sure to implement the methods in the URLSessionTaskDelegate and URLSessionDelegate protocols to handle events common to all task types and session-level events, respectively.

func urlSession(URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo: URL)

func urlSession(URLSession, downloadTask: URLSessionDownloadTask, didResumeAtOffset: Int64, expectedTotalBytes: Int64)

func urlSession(URLSession, downloadTask: URLSessionDownloadTask, didWriteData: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64)

func downloadTask(with: URL) -> URLSessionDownloadTask
Creates a download task that retrieves the contents of the specified URL and saves the results to a file.

func downloadTask(with: URL, completionHandler: (URL?, URLResponse?, Error?) -> Void) -> URLSessionDownloadTask

Creates a download task that retrieves the contents of the specified URL, saves the results to a file, and calls a handler upon completion.

class YourDownloadDelegate: YourAPPDelegate, URLSessionDownloadDelegate {

/