<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 12.3.0 -",
    "tvOS: 15.4.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLMultiArray/withUnsafeBytes(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "s:So12MLMultiArrayC6CoreMLE15withUnsafeBytesyxxSWKXEKlF"
  },
  "title" : "withUnsafeBytes(_:)"
}
-->

# withUnsafeBytes(_:)

Calls a given closure with a raw pointer to the multiarray’s storage.

```
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
```

## Parameters

`body`

A closure with an <doc://com.apple.documentation/documentation/Swift/UnsafeRawBufferPointer> parameter that points to the storage for the multiarray. This closure takes the following parameter:

- `ptr`: The pointer to the buffer.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)