Invalidates the session, allowing any outstanding tasks to finish.
SDKs
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
func 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 url
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 invalidate
instead.
Important
Calling this method on the session returned by the shared
method has no effect.