---
title: CFMutableData
framework: corefoundation
role: symbol
role_heading: Class
path: corefoundation/cfmutabledata
---

# CFMutableData

## Declaration

```swift
class CFMutableData
```

## Overview

Overview CFMutableData manages dynamic binary data. The basic interface for managing binary data is provided by CFData. CFMutableData adds functions to modify the contents of a binary data object. You create a mutable data object using either the CFDataCreateMutable(_:_:) or CFDataCreateMutableCopy(_:_:_:) function. Bytes are added to a data object with the CFDataAppendBytes(_:_:_:) function. Bytes are removed from a data object with the CFDataDeleteBytes(_:_:) function. important: Many of the CFMutableData functions take a CFIndex length or capacity argument. You must not pass a negative number for such values—this may introduce a security risk. CFMutableData is “toll-free bridged” with its Cocoa Foundation counterpart, NSMutableData. What this means is that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. In other words, in a method where you see an NSMutableData * parameter, you can pass in a CFMutableDataRef, and in a function where you see a CFMutableDataRef parameter, you can pass in an NSMutableData instance. This also applies to concrete subclasses of NSMutableData. See Toll-Free Bridged Types for more information on toll-free bridging.

## Topics

### Creating a Mutable Data Object

- [CFDataCreateMutable(_:_:)](corefoundation/cfdatacreatemutable(_:_:).md)
- [CFDataCreateMutableCopy(_:_:_:)](corefoundation/cfdatacreatemutablecopy(_:_:_:).md)

### Accessing Data

- [CFDataGetMutableBytePtr(_:)](corefoundation/cfdatagetmutablebyteptr(_:).md)

### Modifying a Mutable Data Object

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

## Relationships

### Inherits From

- [CFData](corefoundation/cfdata.md)

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Related Documentation

- [Property List Programming Topics for Core Foundation](apple-archive/documentation/CoreFoundation/Conceptual/CFPropertyLists.md)
- [Binary Data Programming Guide for Core Foundation](apple-archive/documentation/CoreFoundation/Conceptual/CFBinaryData.md)

### Opaque Types

- [CFAllocator](corefoundation/cfallocator.md)
- [CFArray](corefoundation/cfarray.md)
- [CFAttributedString](corefoundation/cfattributedstring.md)
- [CFBag](corefoundation/cfbag.md)
- [CFBinaryHeap](corefoundation/cfbinaryheap.md)
- [CFBitVector](corefoundation/cfbitvector.md)
- [CFBoolean](corefoundation/cfboolean.md)
- [CFBundle](corefoundation/cfbundle.md)
- [CFCalendar](corefoundation/cfcalendar.md)
- [CFCharacterSet](corefoundation/cfcharacterset.md)
- [CFData](corefoundation/cfdata.md)
- [CFDate](corefoundation/cfdate.md)
- [CFDateFormatter](corefoundation/cfdateformatter.md)
- [CFDictionary](corefoundation/cfdictionary.md)
- [CFError](corefoundation/cferror.md)
