---
title: "CFDataCreate(_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfdatacreate(_:_:_:)"
---

# CFDataCreate(_:_:_:)

Creates an immutable CFData object using data copied from a specified byte buffer.

## Declaration

```swift
func CFDataCreate(_ allocator: CFAllocator!, _ bytes: UnsafePointer<UInt8>!, _ length: CFIndex) -> CFData!
```

## Parameters

- `allocator`: The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
- `bytes`: A pointer to the byte buffer that contains the raw data to be copied into theData.
- `length`: The number of bytes in the buffer (bytes).

## Return Value

Return Value A new CFData object, or NULL if there was a problem creating the object. Ownership follows the The Create Rule.

## Discussion

Discussion You must supply a count of the bytes in the buffer. This function always copies the bytes in the provided buffer into internal storage.

## See Also

### Creating a CFData Object

- [CFDataCreateCopy(_:_:)](corefoundation/cfdatacreatecopy(_:_:).md)
- [CFDataCreateWithBytesNoCopy(_:_:_:_:)](corefoundation/cfdatacreatewithbytesnocopy(_:_:_:_:).md)
