The URLSession service uses an instance of the URLSessionTask class to make the call to the service that we are connecting to. The URLSessionTask class is a base class, and Apple has provided three concrete subclasses that we can use:
- URLSessionDataTask: This returns the response, in memory, directly to the application as one or more data objects. This is the task that we generally use most often.
- URLSessionDownloadTask: This writes the response directly to a temporary file.
- URLSessionUploadTask: This is used for making requests that require a request body, such as a POST or PUT request.
It is important to note that a task will not send the request to the service until we call the resume() method.