<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextSelection/Affinity-swift.enum",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@E@NSTextSelectionAffinity"
  },
  "title" : "NSTextSelection.Affinity"
}
-->

# NSTextSelection.Affinity

Values that describe the visual location of the text cursor, or the direction of the non-anchored edge of the selection.

```
enum Affinity
```

## Topics

### Affinities

[`case downstream`](/documentation/AppKit/NSTextSelection/Affinity-swift.enum/downstream)

The value that defines the visual location of the text cursor between the head of line that contains the selection location.

[`case upstream`](/documentation/AppKit/NSTextSelection/Affinity-swift.enum/upstream)

The value that defines the visual location of the text cursor to the tail of the previous line.

### Initializers

[`init?(rawValue: Int)`](/documentation/AppKit/NSTextSelection/Affinity-swift.enum/init(rawValue:))

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`Equatable`](/documentation/Swift/Equatable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`Hashable`](/documentation/Swift/Hashable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)