<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMMutableDataBlockBuffer/replaceSubrange(_:with:)-5w62q",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "s:9CoreMedia24CMMutableDataBlockBufferV15replaceSubrange_4withySnySiG_xt10Foundation0D8ProtocolRzlF"
  },
  "title" : "replaceSubrange(_:with:)"
}
-->

# replaceSubrange(_:with:)

Replace a range of bytes in the block buffer.

```
mutating func replaceSubrange(_ range: Range<Int>, with bytes: some DataProtocol)
```

## Parameters

`range`

Range of bytes to replace within this buffer. The count of this range must match the count of `bytes`.

`bytes`

The replacement data.

## Discussion

This function also works if the range covers non-contiguous regions of memory.

---

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)