---
title: "addOperation(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/operationqueue/addoperation(_:)-64o8a"
---

# addOperation(_:)

Adds the specified operation to the receiver.

## Declaration

```swift
func addOperation(_ op: Operation)
```

## Parameters

- `op`: The operation to be added to the queue.

## Discussion

Discussion Once added, the specified operation remains in the queue until it finishes executing. important: An operation object can be in at most one operation queue at a time and this method throws an invalidArgumentException exception if the operation is already in another queue. Similarly, this method throws an invalidArgumentException exception if the operation is currently executing or has already finished executing.

## See Also

### Related Documentation

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

### Managing Operations in the Queue

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