---
title: "CFDataReplaceBytes(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfdatareplacebytes(_:_:_:_:)"
---

# CFDataReplaceBytes(_:_:_:_:)

Replaces those bytes in a CFMutableData object that fall within a specified range with other bytes.

## Declaration

```swift
func CFDataReplaceBytes(_ theData: CFMutableData!, _ range: CFRange, _ newBytes: UnsafePointer<UInt8>!, _ newLength: CFIndex)
```

## Parameters

- `theData`: A CFMutableData object. If you pass an immutable CFData object, the behavior is not defined.
- `range`: The range of bytes (that is, the starting byte and the number of bytes from that point) to delete from theData’s byte buffer.
- `newBytes`: A pointer to the buffer containing the replacement bytes.
- `newLength`: The number of bytes in the byte buffer newBytes.

## See Also

### Modifying a Mutable Data Object

- [CFDataAppendBytes(_:_:_:)](corefoundation/cfdataappendbytes(_:_:_:).md)
- [CFDataDeleteBytes(_:_:)](corefoundation/cfdatadeletebytes(_:_:).md)
- [CFDataIncreaseLength(_:_:)](corefoundation/cfdataincreaselength(_:_:).md)
- [CFDataSetLength(_:_:)](corefoundation/cfdatasetlength(_:_:).md)
