---
title: "subscript(_:)"
framework: swiftui
role: symbol
role_heading: Instance Subscript
path: "swiftui/attributedtextselection/attributes/subscript(_:)"
---

# subscript(_:)

Returns a sequence which iterates of the values of a single attribute.

## Declaration

```swift
subscript<K>(type: K.Type) -> some Sequence<Optional<K.Value>> where K : AttributedStringKey, K.Value : Sendable { get }
```

## Overview

Overview In the case of a range selection, the returned sequence is based on the runs of the specified attribute, not the runs over all attributes. selection.attributes(in: text)[MyAttribute.self].contains(myValue)
