---
title: AttributeContainer
framework: foundation
role: symbol
role_heading: Structure
path: foundation/attributecontainer
---

# AttributeContainer

A container for attribute keys and values.

## Declaration

```swift
@dynamicMemberLookup struct AttributeContainer
```

## Overview

Overview AttributeContainer provides a way to store attributes and their values outside of an attributed string. You use this type to initialize an instance of AttributedString with preset attributes, and to set, merge, or replace attributes in existing attributed strings.

## Topics

### Creating an Attribute Container

- [init()](foundation/attributecontainer/init().md)
- [init(_:including:)](foundation/attributecontainer/init(_:including:)-2mw0o.md)
- [init(_:including:)](foundation/attributecontainer/init(_:including:)-28n0g.md)
- [init(_:)](foundation/attributecontainer/init(_:).md)

### Accessing Attributes

- [subscript(_:)](foundation/attributecontainer/subscript(_:).md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-657oj.md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-3jcvx.md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-60ps5.md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-swift.type.subscript.md)
- [AttributedStringKey](foundation/attributedstringkey.md)
- [AttributeContainer.Builder](foundation/attributecontainer/builder.md)

### Modifying Attributes

- [merge(_:mergePolicy:)](foundation/attributecontainer/merge(_:mergepolicy:).md)
- [merging(_:mergePolicy:)](foundation/attributecontainer/merging(_:mergepolicy:).md)
- [AttributedString.AttributeMergePolicy](foundation/attributedstring/attributemergepolicy.md)

### Interoperating with Objective-C Attributes

- [ObjectiveCConvertibleAttributedStringKey](foundation/objectivecconvertibleattributedstringkey.md)

### Instance Methods

- [filter(inheritedByAddedText:)](foundation/attributecontainer/filter(inheritedbyaddedtext:).md)
- [filter(runBoundaries:)](foundation/attributecontainer/filter(runboundaries:).md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [DecodableWithConfiguration](foundation/decodablewithconfiguration.md)
- [EncodableWithConfiguration](foundation/encodablewithconfiguration.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Creating an Attributed String

- [init()](foundation/attributedstring/init().md)
- [init(_:)](foundation/attributedstring/init(_:)-8tnoq.md)
- [init(_:attributes:)](foundation/attributedstring/init(_:attributes:)-2a45h.md)
- [init(_:attributes:)](foundation/attributedstring/init(_:attributes:)-8jqhp.md)
- [init(_:attributes:)](foundation/attributedstring/init(_:attributes:)-8l0iq.md)
