---
title: "withUnsafeMutableBytes(_:)"
framework: coreai
role: symbol
role_heading: Instance Method
platforms: [iOS 27.0+, iPadOS 27.0+, tvOS 27.0+, visionOS 27.0+, watchOS 27.0+]
path: "coreai/ndarray/mutablerawview/withunsafemutablebytes(_:)"
---

# withUnsafeMutableBytes(_:)

Invokes the provided closure with the backing data and memory layout of this view.

## Declaration

```swift
@export(implementation) consuming func withUnsafeMutableBytes<R, E>(_ body: (UnsafeMutableRawPointer, Span<Int>, Span<Int>) throws(E) -> R) throws(E) -> R where E : Error
```

## Return Value

Return Value The value returned by the closure.

## Discussion

Discussion body: The closure to be invoked with a mutable raw pointer to the first element, as well as shape and strides of the view. You are responsible for reading the strides passed in when indexing the backing data. If the view has an interleaveLayout, the strides for that dimension are block strides and must be interpreted accordingly — see NDArray.InterleaveLayout.
