---
title: "replaceUnsafeMutableBytes(bufferIndex:_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowlevelmesh/replaceunsafemutablebytes(bufferindex:_:)"
---

# replaceUnsafeMutableBytes(bufferIndex:_:)

Replaces a Metal vertex buffer synchronously on the CPU.

## Declaration

```swift
@MainActor func replaceUnsafeMutableBytes(bufferIndex: Int, _ callback: (UnsafeMutableRawBufferPointer) -> Void)
```

## Discussion

Discussion The buffer’s contents are unspecified, and it is the caller’s responsibility to populate the buffer with valid data. The buffer is only valid for the lifetime of the callback.

## See Also

### Accessing mesh data on the CPU with Swift

- [withUnsafeBytes(bufferIndex:_:)](realitykit/lowlevelmesh/withunsafebytes(bufferindex:_:).md)
- [withUnsafeMutableBytes(bufferIndex:_:)](realitykit/lowlevelmesh/withunsafemutablebytes(bufferindex:_:).md)
- [withUnsafeIndices(_:)](realitykit/lowlevelmesh/withunsafeindices(_:).md)
- [withUnsafeMutableIndices(_:)](realitykit/lowlevelmesh/withunsafemutableindices(_:).md)
- [replaceUnsafeMutableIndices(_:)](realitykit/lowlevelmesh/replaceunsafemutableindices(_:).md)
