NSURLSessionDataTask Class Reference
Available in iOS 7.0 and later.
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:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:method with status information.
After receiving an initial response, the session calls its delegate’s
URLSession:dataTask:didReceiveResponse:completionHandler:method to let you examine the status code and headers, and optionally convert the data task into a download task.
During the transfer, the session calls its delegate’s
URLSession:dataTask:didReceiveData:method to provide your app with the content as it arrives.
Upon completion, the session calls its delegate’s
URLSession:dataTask:willCacheResponse:completionHandler:method to let you determine whether the response should be cached.
For a detailed explanation of this process, read URL Loading System Programming Guide.