---
title: "affinity(in:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/attributedtextselection/affinity(in:)"
---

# affinity(in:)

Return the selection affinity of the selection.

## Declaration

```swift
func affinity(in text: AttributedString) -> TextSelectionAffinity
```
