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
urlmethod with status information.
Session(_: task: did Send Body Data: total Bytes Sent: total Bytes Expected To Send:)
After receiving an initial response, the session calls its delegate’s
urlmethod to let you examine the status code and headers, and optionally convert the data task into a download task.
Session(_: data Task: did Receive: completion Handler:)
During the transfer, the session calls its delegate’s
urlmethod to provide your app with the content as it arrives.
Session(_: data Task: did Receive:)
Upon completion, the session calls its delegate’s
urlmethod to let you determine whether the response should be cached.
Session(_: data Task: will Cache Response: completion Handler:)
For a detailed explanation of this process, read URL Session Programming Guide.