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

# withUnsafeBytes(for:_:)

## Declaration

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