<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFDataReplaceBytes(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFDataReplaceBytes"
  },
  "title" : "CFDataReplaceBytes(_:_:_:_:)"
}
-->

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

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

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

## 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)