Instance Method

URLSession:task:didCompleteWithError:

Tells the delegate that the task finished transferring data.

Declaration

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error;

Parameters

session

The session containing the task whose request finished transferring data.

task

The task whose request finished transferring data.

error

If an error occurred, an error object indicating how the transfer failed, otherwise NULL.

Discussion

Server errors are not reported through the error parameter. The only errors your delegate receives through the error parameter are client-side errors, such as being unable to resolve the hostname or connect to the host.

See Also

Delegate Methods

URLSession:task:didReceiveChallenge:completionHandler:

Requests credentials from the delegate in response to an authentication request from the remote server.

URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:

Periodically informs the delegate of the progress of sending body content to the server.

URLSession:task:needNewBodyStream:

Tells the delegate when a task requires a new request body stream to send to the remote server.

URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:

Tells the delegate that the remote server requested an HTTP redirect.

URLSession:task:didFinishCollectingMetrics:

Tells the delegate that the session finished collecting metrics for the task.

NSURLSessionTaskMetrics

An NSURLSessionTaskMetrics object encapsulates the metrics for a session task. Each object contains the taskInterval and redirectCount, as well as metrics for each request / response transaction made during the execution of the task.