---
title: "init(_:including:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/attributecontainer/init(_:including:)-28n0g"
---

# init(_:including:)

Creates an attribute container from a dictionary and an attribute scope that a key path identifies.

## Declaration

```swift
init<S>(_ dictionary: [NSAttributedString.Key : Any], including scope: KeyPath<AttributeScopes, S.Type>) throws where S : AttributeScope
```

## Parameters

- `dictionary`: A dictionary of attribute keys and their values.
- `scope`: A key path that identifies the attribute scope of the dictionary keys. This can be a nested scope that contains several scopes.

## Discussion

Discussion This initializer only collects attributes from dictionary that exist in the provided scope. The resulting attribute container omits any keys in dictionary that don’t exist in scope.

## See Also

### Creating an Attribute Container

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