---
title: "xpc_data_get_bytes(_:_:_:_:)"
framework: xpc
role: symbol
role_heading: Function
path: "xpc/xpc_data_get_bytes(_:_:_:_:)"
---

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

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

## Declaration

```swift
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

Return Value The number of bytes that were copied into the buffer.

## See Also

### Data objects

- [xpc_data_create(_:_:)](xpc/xpc_data_create(_:_:).md)
- [xpc_data_create_with_dispatch_data(_:)](xpc/xpc_data_create_with_dispatch_data(_:).md)
- [xpc_data_get_bytes_ptr(_:)](xpc/xpc_data_get_bytes_ptr(_:).md)
- [xpc_data_get_length(_:)](xpc/xpc_data_get_length(_:).md)
