<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFMutableArray",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFMutableArrayRef"
  },
  "title" : "CFMutableArray"
}
-->

# CFMutableArray

```
class CFMutableArray
```

## Overview

CFMutableArray manages dynamic arrays. The basic interface for managing arrays is provided by [`CFArray`](/documentation/CoreFoundation/CFArray). CFMutableArray adds functions to modify the contents of an array.

You create a mutable array object using either the [`CFArrayCreateMutable(_:_:_:)`](/documentation/CoreFoundation/CFArrayCreateMutable(_:_:_:)) or [`CFArrayCreateMutableCopy(_:_:_:)`](/documentation/CoreFoundation/CFArrayCreateMutableCopy(_:_:_:)) function.

CFMutableArray provides several functions for changing the contents of an array, for example the [`CFArrayAppendValue(_:_:)`](/documentation/CoreFoundation/CFArrayAppendValue(_:_:)) and [`CFArrayInsertValueAtIndex(_:_:_:)`](/documentation/CoreFoundation/CFArrayInsertValueAtIndex(_:_:_:)) functions add values to an array and [`CFArrayRemoveValueAtIndex(_:_:)`](/documentation/CoreFoundation/CFArrayRemoveValueAtIndex(_:_:)) removes values from an array. You can also reorder the contents of an array using [`CFArrayExchangeValuesAtIndices(_:_:_:)`](/documentation/CoreFoundation/CFArrayExchangeValuesAtIndices(_:_:_:)) and [`CFArraySortValues(_:_:_:_:)`](/documentation/CoreFoundation/CFArraySortValues(_:_:_:_:)).

CFMutableArray is “toll-free bridged” with its Cocoa Foundation counterpart, <doc://com.apple.documentation/documentation/Foundation/NSMutableArray>. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an `NSMutableArray *` parameter, you can pass in a `CFMutableArrayRef`, and in a function where you see a `CFMutableArrayRef` parameter, you can pass in an NSMutableArray instance. This fact also applies to concrete subclasses of NSMutableArray. See [Toll-Free Bridged Types](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFDesignConcepts/Articles/tollFreeBridgedTypes.html#//apple_ref/doc/uid/TP40010677) for more information on toll-free bridging.

## Topics

### CFMutableArray Miscellaneous Functions

[`CFArrayAppendArray(_:_:_:)`](/documentation/CoreFoundation/CFArrayAppendArray(_:_:_:))

Adds the values from one array to another array.

[`CFArrayAppendValue(_:_:)`](/documentation/CoreFoundation/CFArrayAppendValue(_:_:))

Adds a value to an array giving it the new largest index.

[`CFArrayCreateMutable(_:_:_:)`](/documentation/CoreFoundation/CFArrayCreateMutable(_:_:_:))

Creates a new empty mutable array.

[`CFArrayCreateMutableCopy(_:_:_:)`](/documentation/CoreFoundation/CFArrayCreateMutableCopy(_:_:_:))

Creates a new mutable array with the values from another array.

[`CFArrayExchangeValuesAtIndices(_:_:_:)`](/documentation/CoreFoundation/CFArrayExchangeValuesAtIndices(_:_:_:))

Exchanges the values at two indices of an array.

[`CFArrayInsertValueAtIndex(_:_:_:)`](/documentation/CoreFoundation/CFArrayInsertValueAtIndex(_:_:_:))

Inserts a value into an array at a given index.

[`CFArrayRemoveAllValues(_:)`](/documentation/CoreFoundation/CFArrayRemoveAllValues(_:))

Removes all the values from an array, making it empty.

[`CFArrayRemoveValueAtIndex(_:_:)`](/documentation/CoreFoundation/CFArrayRemoveValueAtIndex(_:_:))

Removes the value at a given index from an array.

[`CFArrayReplaceValues(_:_:_:_:)`](/documentation/CoreFoundation/CFArrayReplaceValues(_:_:_:_:))

Replaces a range of values in an array.

[`CFArraySetValueAtIndex(_:_:_:)`](/documentation/CoreFoundation/CFArraySetValueAtIndex(_:_:_:))

Changes the value at a given index in an array.

[`CFArraySortValues(_:_:_:_:)`](/documentation/CoreFoundation/CFArraySortValues(_:_:_:_:))

Sorts the values in an array using a given comparison function.

## See Also

  [Collections Programming Topics for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFCollections/CFCollections.html#//apple_ref/doc/uid/10000124i)



---

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)