A URL session task that returns downloaded data directly to the app in memory.
- iOS 7.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 2.0+
A data task returns data directly to the app (in memory) as one or more
NSData objects. When you use a data task:
During upload of the body data (if your app provides any), the session periodically calls its delegate’s
URLSession:method with status information.
task: did Send Body Data: total Bytes Sent: total Bytes Expected To Send:
After receiving an initial response, the session calls its delegate’s
URLSession:method to let you examine the status code and headers, and optionally convert the data task into a download task.
data Task: did Receive Response: completion Handler:
During the transfer, the session calls its delegate’s
URLSession:method to provide your app with the content as it arrives.
data Task: did Receive Data:
Upon completion, the session calls its delegate’s
URLSession:method to let you determine whether the response should be cached.
data Task: will Cache Response: completion Handler:
For a detailed explanation of this process, read URL Session Programming Guide.