Cancels the task.
- iOS 7.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 2.0+
- Mac Catalyst 13.0+Beta
This method returns immediately, marking the task as being canceled. Once a task is marked as being canceled,
URLSession: will be sent to the task delegate, passing an error in the domain
NSURLError with the code
NSURLError. A task may, under some circumstances, send messages to its delegate before the cancelation is acknowledged.
This method may be called on a task that is suspended.