Instance Method


Cancels the task.


- (void)cancel;


This method returns immediately, marking the task as being canceled. Once a task is marked as being canceled, URLSession:task:didCompleteWithError: will be sent to the task delegate, passing an error in the domain NSURLErrorDomain with the code NSURLErrorCancelled. 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.

See Also

Controlling the Task State

- resume

Resumes the task, if it is suspended.

- suspend

Temporarily suspends a task.


The current state of the task—active, suspended, in the process of being canceled, or completed.


Constants for determining the current state of a task.


The relative priority at which you’d like a host to handle the task, specified as a floating point value between 0.0 (lowest priority) and 1.0 (highest priority).

URL Session Task Priority

Constants for providing task priority hints to a host, used with the priority property.