---
title: "init(_:including:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/attributedstring/init(_:including:)-puv0"
---

# init(_:including:)

Creates a value-type attributed string from a reference type, including an attribute scope that a key path identifies.

## Declaration

```swift
init<S>(_ nsStr: NSAttributedString, including scope: KeyPath<AttributeScopes, S.Type>) throws where S : AttributeScope
```

## Parameters

- `nsStr`: The doc://com.apple.foundation/documentation/Foundation/NSAttributedString to convert.
- `scope`: A key path that identifies the attribute scope of the attributes in nsStr. This can be a nested scope that contains several scopes.

## Discussion

Discussion This initializer only collects attributes from nsStr that exist in the provided scope. The resulting attributed string omits any keys in nsStr that don’t exist in scope.

## See Also

### Creating an Attributed String from a Reference Type

- [init(_:including:)](foundation/attributedstring/init(_:including:)-9no47.md)
- [init(_:)](foundation/attributedstring/init(_:)-1fru0.md)
