<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/OperationQueue/addBarrierBlock(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOperationQueue(im)addBarrierBlock:"
  },
  "title" : "addBarrierBlock(_:)"
}
-->

# addBarrierBlock(_:)

Invokes a block when the queue finishes all enqueued operations, and prevents subsequent operations from starting until the block has completed.

```
func addBarrierBlock(_ barrier: @escaping @Sendable () -> Void)
```

## Parameters

`barrier`

The block to invoke after all currently enqueued operations have finished. Operations you add after the barrier block don’t start until the block has completed.

## Discussion

This method is similar to <doc://com.apple.documentation/documentation/Dispatch/dispatch_barrier_async>.

---

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)