---
title: "addAttributes(_:range:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutableattributedstring/addattributes(_:range:)"
---

# addAttributes(_:range:)

Adds the given collection of attributes to the characters in the specified range.

## Declaration

```swift
func addAttributes(_ attrs: [NSAttributedString.Key : Any] = [:], range: NSRange)
```

## Parameters

- `attrs`: A dictionary containing the attributes to add. Attribute keys can be supplied by another framework or can be custom ones you define. For information about the system-supplied attribute keys, see the Constants section in doc://com.apple.foundation/documentation/Foundation/NSAttributedString.
- `range`: The range of characters to which the specified attributes apply.

## Discussion

Discussion You may assign any name/value pair you wish to a range of characters. Raises an invalidArgumentException if attrs is nil and an rangeException if any part of range lies beyond the end of the receiver’s characters.

## See Also

### Changing Attributes

- [setAttributes(_:range:)](foundation/nsmutableattributedstring/setattributes(_:range:).md)
- [addAttribute(_:value:range:)](foundation/nsmutableattributedstring/addattribute(_:value:range:).md)
- [removeAttribute(_:range:)](foundation/nsmutableattributedstring/removeattribute(_:range:).md)
- [applyFontTraits(_:range:)](foundation/nsmutableattributedstring/applyfonttraits(_:range:).md)
- [setAlignment(_:range:)](foundation/nsmutableattributedstring/setalignment(_:range:).md)
- [setBaseWritingDirection(_:range:)](foundation/nsmutableattributedstring/setbasewritingdirection(_:range:).md)
- [subscriptRange(_:)](foundation/nsmutableattributedstring/subscriptrange(_:).md)
- [superscriptRange(_:)](foundation/nsmutableattributedstring/superscriptrange(_:).md)
- [unscriptRange(_:)](foundation/nsmutableattributedstring/unscriptrange(_:).md)
