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

# CFMutableBag

```
class CFMutableBag
```

## Overview

CFMutableBag manages dynamic bags. The basic interface for managing bags is provided by [`CFBag`](/documentation/CoreFoundation/CFBag). CFMutableBag adds functions to modify the contents of a bag.

You create a mutable bag object using either the [`CFBagCreateMutable(_:_:_:)`](/documentation/CoreFoundation/CFBagCreateMutable(_:_:_:)) or [`CFBagCreateMutableCopy(_:_:_:)`](/documentation/CoreFoundation/CFBagCreateMutableCopy(_:_:_:)) function.

CFMutableBag provides several functions for adding and removing values from a bag. The [`CFBagAddValue(_:_:)`](/documentation/CoreFoundation/CFBagAddValue(_:_:)) function adds a value to a bag and [`CFBagRemoveValue(_:_:)`](/documentation/CoreFoundation/CFBagRemoveValue(_:_:)) removes values from a bag.

## Topics

### Creating a Mutable Bag

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

Creates a new empty mutable bag.

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

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

### Modifying a Mutable Bag

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

Adds a value to a mutable bag.

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

Removes all values from a mutable bag.

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

Removes a value from a mutable bag.

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

Replaces a value in a mutable bag.

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

Sets a value in a mutable bag.

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