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

# withUnsafeMutableBytes(bufferIndex:_:)

Updates a Metal vertex buffer synchronously on the CPU.

## Declaration

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

## Discussion

Discussion 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)
- [withUnsafeIndices(_:)](realitykit/lowlevelmesh/withunsafeindices(_:).md)
- [withUnsafeMutableIndices(_:)](realitykit/lowlevelmesh/withunsafemutableindices(_:).md)
- [replaceUnsafeMutableBytes(bufferIndex:_:)](realitykit/lowlevelmesh/replaceunsafemutablebytes(bufferindex:_:).md)
- [replaceUnsafeMutableIndices(_:)](realitykit/lowlevelmesh/replaceunsafemutableindices(_:).md)
