In latest apple introduce new NSURLSession in replace of NSURLConnection, so in there are different task , so what is the difference between
Adding to the previous answers: Apple made it clear in their guide "URL Loading System"
For small interactions with remote servers, you can use the URLSessionDataTask class to receive response data into memory (as opposed to using the URLSessionDownloadTask class, which stores the data directly to the file system). A data task is ideal for uses like calling a web service endpoint.
https://developer.apple.com/documentation/foundation/url_loading_system/fetching_website_data_into_memory#overview