Instance Method

finishTasksAndInvalidate

Invalidates the session, allowing any outstanding tasks to finish.

Declaration

- (void)finishTasksAndInvalidate;

Discussion

This method returns immediately without waiting for tasks to finish. Once a session is invalidated, new tasks cannot be created in the session, but existing tasks continue until completion. After the last task finishes and the session makes the last delegate call related to those tasks, the session calls the URLSession:didBecomeInvalidWithError: method on its delegate, then breaks references to the delegate and callback objects. After invalidation, session objects cannot be reused.

To cancel all outstanding tasks, call invalidateAndCancel instead.

See Also

Managing the Session

- flushWithCompletionHandler:

Flushes cookies and credentials to disk, clears transient caches, and ensures that future requests occur on a new TCP connection.

- getTasksWithCompletionHandler:

Asynchronously calls a completion callback with all data, upload, and download tasks in a session.

- getAllTasksWithCompletionHandler:

Asynchronously calls a completion callback with all tasks in a session

- invalidateAndCancel

Cancels all outstanding tasks and then invalidates the session.

- resetWithCompletionHandler:

Empties all cookies, caches and credential stores, removes disk files, flushes in-progress downloads to disk, and ensures that future requests occur on a new socket.

sessionDescription

An app-defined descriptive label for the session.