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

# xpc_data_create(_:_:)

Creates an XPC object that represents a buffer of bytes.

## Declaration

```swift
func xpc_data_create(_ bytes: UnsafeRawPointer?, _ length: Int) -> xpc_object_t
```

## Parameters

- `bytes`: The buffer of bytes which is to be boxed. You may create an empty data object by passing NULL for this parameter and 0 for the length. Passing NULL with any other length will result in undefined behavior.
- `length`: The number of bytes which are to be boxed.

## Return Value

Return Value A new data object.

## Discussion

Discussion This method will copy the buffer given into internal storage. After calling this method, it is safe to dispose of the given buffer.

## See Also

### Data objects

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