---
title: addBarrier()
framework: metal
role: symbol
role_heading: Instance Method
path: metal/mtliocommandbuffer/addbarrier()
---

# addBarrier()

Encodes a barrier into the command buffer.

## Declaration

```swift
func addBarrier()
```

## Discussion

Discussion The method encodes a barrier that starts any subsequent commands only after all the previously encoded commands have completed.
