<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc_data_get_bytes(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_data_get_bytes"
  },
  "title" : "xpc_data_get_bytes(_:_:_:_:)"
}
-->

# xpc_data_get_bytes(_:_:_:_:)

Copies the bytes in a data object into the specified buffer.

```
func xpc_data_get_bytes(_ xdata: xpc_object_t, _ buffer: UnsafeMutableRawPointer, _ off: Int, _ length: Int) -> Int
```

## Parameters

`xdata`

The data object which is to be examined.

`buffer`

The buffer in which to copy the data object’s bytes.

`off`

The offset at which to begin the copy. If this offset is greater than the length of the data element, nothing is copied. Pass 0 to start the copy at the beginning of the buffer.

`length`

The length of the destination buffer.

## Return Value

The number of bytes that were copied into the buffer.

## Discussion

---

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)