<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/OperationQueue/addOperation(_:)-5s294",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOperationQueue(im)addOperationWithBlock:"
  },
  "title" : "addOperation(_:)"
}
-->

# addOperation(_:)

Wraps the specified block in an operation and adds it to the receiver.

```
func addOperation(_ block: @escaping @Sendable () -> Void)
```

## Parameters

`block`

The block to execute from the operation. The block takes no parameters and has no return value.

## Discussion

This method adds a single block to the receiver by first wrapping it in an operation object. You should not attempt to get a reference to the newly created operation object or determine its type information.

## See Also

[`cancel()`](/documentation/Foundation/Operation/cancel())

Advises the operation object that it should stop executing its task.

[`isExecuting`](/documentation/Foundation/Operation/isExecuting)

A Boolean value indicating whether the operation is currently executing.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)