---
title: "CFAttributedStringSetAttributes(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfattributedstringsetattributes(_:_:_:_:)"
---

# CFAttributedStringSetAttributes(_:_:_:_:)

Sets the value of attributes of a mutable attributed string over a specified range.

## Declaration

```swift
func CFAttributedStringSetAttributes(_ aStr: CFMutableAttributedString!, _ range: CFRange, _ replacement: CFDictionary!, _ clearOtherAttributes: Bool)
```

## Parameters

- `aStr`: The mutable attributed string to modify.
- `range`: The range of aStr over to which the new attributes apply. range must not exceed the bounds of aStr.
- `replacement`: A dictionary that contains key-value pairs that specify the new attributes to apply to range. The keys must be CFString objects, and the corresponding values must be CFType objects.
- `clearOtherAttributes`: If false, existing attributes (that aren’t being replaced) are left alone; otherwise they are cleared.

## Discussion

Discussion Note that after this call, if it is mutable, changes to replacement will not affect the contents of the attributed string.

## See Also

### Modifying a CFMutableAttributedString

- [CFAttributedStringBeginEditing(_:)](corefoundation/cfattributedstringbeginediting(_:).md)
- [CFAttributedStringEndEditing(_:)](corefoundation/cfattributedstringendediting(_:).md)
- [CFAttributedStringGetMutableString(_:)](corefoundation/cfattributedstringgetmutablestring(_:).md)
- [CFAttributedStringRemoveAttribute(_:_:_:)](corefoundation/cfattributedstringremoveattribute(_:_:_:).md)
- [CFAttributedStringReplaceString(_:_:_:)](corefoundation/cfattributedstringreplacestring(_:_:_:).md)
- [CFAttributedStringReplaceAttributedString(_:_:_:)](corefoundation/cfattributedstringreplaceattributedstring(_:_:_:).md)
- [CFAttributedStringSetAttribute(_:_:_:_:)](corefoundation/cfattributedstringsetattribute(_:_:_:_:).md)
