---
title: "CFBagSetValue(_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfbagsetvalue(_:_:)"
---

# CFBagSetValue(_:_:)

Sets a value in a mutable bag.

## Declaration

```swift
func CFBagSetValue(_ theBag: CFMutableBag!, _ value: UnsafeRawPointer!)
```

## Parameters

- `theBag`: The bag in which value is to be set.
- `value`: The value to be set in the collection. If this value already exists in theBag, it is replaced. You may pass the value itself instead of a pointer to it if the value is pointer-size or less. If theBag is fixed-size and the value is beyond its capacity, the behavior is undefined.

## Discussion

Discussion Depending on the implementation of the equal callback specified when creating theBag, the value that is replaced by value may not have the same pointer equality.

## See Also

### Modifying a Mutable Bag

- [CFBagAddValue(_:_:)](corefoundation/cfbagaddvalue(_:_:).md)
- [CFBagRemoveAllValues(_:)](corefoundation/cfbagremoveallvalues(_:).md)
- [CFBagRemoveValue(_:_:)](corefoundation/cfbagremovevalue(_:_:).md)
- [CFBagReplaceValue(_:_:)](corefoundation/cfbagreplacevalue(_:_:).md)
