---
title: "mergeAttributes(_:mergePolicy:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributedsubstring/mergeattributes(_:mergepolicy:)"
---

# mergeAttributes(_:mergePolicy:)

Merges the attributed string’s attributes with those in a specified attribute container.

## Declaration

```swift
mutating func mergeAttributes(_ attributes: AttributeContainer, mergePolicy: AttributedString.AttributeMergePolicy = .keepNew)
```

## Parameters

- `attributes`: The attribute container with the attributes to merge.
- `mergePolicy`: A policy to use when resolving conflicts between this string’s attributes and those in attributes.

## See Also

### Applying and Modifying Attributes

- [setAttributes(_:)](foundation/attributedsubstring/setattributes(_:).md)
- [AttributedString.AttributeMergePolicy](foundation/attributedstring/attributemergepolicy.md)
- [replaceAttributes(_:with:)](foundation/attributedsubstring/replaceattributes(_:with:).md)
