Instance Method

urlSession(_:task:didCompleteWithError:)

Tells the delegate that the task finished transferring data.

Declaration

optional func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: 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

func urlSession(URLSession, task: URLSessionTask, didSendBodyData: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64)

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

func urlSession(URLSession, task: URLSessionTask, needNewBodyStream: (InputStream?) -> Void)

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

func urlSession(URLSession, task: URLSessionTask, didFinishCollecting: URLSessionTaskMetrics)

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

class URLSessionTaskMetrics

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.