---
title: cancelAllOperations()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/operationqueue/cancelalloperations()
---

# cancelAllOperations()

Cancels all queued and executing operations.

## Declaration

```swift
func cancelAllOperations()
```

## Discussion

Discussion This method calls the cancel() method on all operations currently in the queue. Canceling the operations does not automatically remove them from the queue or stop those that are currently executing. For operations that are queued and waiting execution, the queue must still attempt to execute the operation before recognizing that it is canceled and moving it to the finished state. For operations that are already executing, the operation object itself must check for cancellation and stop what it is doing so that it can move to the finished state. In both cases, a finished (or canceled) operation is still given a chance to execute its completion block before it is removed from the queue.

## See Also

### Related Documentation

- [cancel()](foundation/operation/cancel().md)

### Managing Operations in the Queue

- [addOperation(_:)](foundation/operationqueue/addoperation(_:)-64o8a.md)
- [addOperations(_:waitUntilFinished:)](foundation/operationqueue/addoperations(_:waituntilfinished:).md)
- [addOperation(_:)](foundation/operationqueue/addoperation(_:)-5s294.md)
- [addBarrierBlock(_:)](foundation/operationqueue/addbarrierblock(_:).md)
- [waitUntilAllOperationsAreFinished()](foundation/operationqueue/waituntilalloperationsarefinished().md)
- [operations](foundation/operationqueue/operations.md)
- [operationCount](foundation/operationqueue/operationcount.md)
