---
title: "withUnsafeBytes(for:_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/contiguousarray/withunsafebytes(for:_:)"
---

# withUnsafeBytes(for:_:)

## Declaration

```swift
func withUnsafeBytes<R>(for attachment: borrowing Attachment<ContiguousArray<Element>>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R
```
