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

# CFMutableDictionary

```
class CFMutableDictionary
```

## Overview

CFMutableDictionary manages dynamic dictionaries. The basic interface for managing dictionaries is provided by [`CFDictionary`](/documentation/CoreFoundation/CFDictionary). CFMutableDictionary adds functions to modify the contents of a dictionary.

You create a mutable dictionary object using either the [`CFDictionaryCreateMutable(_:_:_:_:)`](/documentation/CoreFoundation/CFDictionaryCreateMutable(_:_:_:_:)) or [`CFDictionaryCreateMutableCopy(_:_:_:)`](/documentation/CoreFoundation/CFDictionaryCreateMutableCopy(_:_:_:)) function. You can add key-value pairs using the [`CFDictionaryAddValue(_:_:_:)`](/documentation/CoreFoundation/CFDictionaryAddValue(_:_:_:)) and [`CFDictionarySetValue(_:_:_:)`](/documentation/CoreFoundation/CFDictionarySetValue(_:_:_:)) functions. When adding key-value pairs to a dictionary, the keys and values are not copied—they are retained so they are not invalidated before the dictionary is deallocated. You can remove key-value pairs using the [`CFDictionaryRemoveValue(_:_:)`](/documentation/CoreFoundation/CFDictionaryRemoveValue(_:_:)) function. When removing key-value pairs from a dictionary, the keys and values are released.

CFMutableDictionary is “toll-free bridged” with its Cocoa Foundation counterpart, <doc://com.apple.documentation/documentation/Foundation/NSMutableDictionary>. What this means is that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. This means that in a method where you see an `NSMutableDictionary *` parameter, you can pass in a `CFMutableDictionaryRef`, and in a function where you see a `CFMutableDictionaryRef` parameter, you can pass in an NSMutableDictionary instance. This also applies to concrete subclasses of NSMutableDictionary. 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

### Creating a Mutable Dictionary

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

Creates a new mutable dictionary.

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

Creates a new mutable dictionary with the key-value pairs from another dictionary.

### Modifying a Dictionary

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

Adds a key-value pair to a dictionary if the specified key is not already present.

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

Removes all the key-value pairs from a dictionary, making it empty.

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

Removes a key-value pair.

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

Replaces a value corresponding to a given key.

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

Sets the value corresponding to a given key.

## See Also

  [Property List Programming Topics for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFPropertyLists/CFPropertyLists.html#//apple_ref/doc/uid/10000130i)

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