<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSelectionAffinity",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@E@NSSelectionAffinity"
  },
  "title" : "NSSelectionAffinity"
}
-->

# NSSelectionAffinity

These constants specify the preferred direction of selection. They’re used by [`selectionAffinity`](/documentation/AppKit/NSTextView/selectionAffinity) and [`setSelectedRange(_:affinity:stillSelecting:)`](/documentation/AppKit/NSTextView/setSelectedRange(_:affinity:stillSelecting:)).

```
enum NSSelectionAffinity
```

## Topics

### Constants

[`NSSelectionAffinityUpstream`](/documentation/AppKit/NSSelectionAffinity/upstream)

The selection is moving toward the top of the document.

[`NSSelectionAffinityDownstream`](/documentation/AppKit/NSSelectionAffinity/downstream)

The selection is moving toward the bottom of the document.

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)