<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/selectedRanges",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(py)selectedRanges"
  },
  "title" : "selectedRanges"
}
-->

# selectedRanges

An array containing the ranges of characters selected in the receiver’s layout manager.

```
var selectedRanges: [NSValue] { get set }
```

## Discussion

The objects in the array are sorted by location in ascending order, non-overlapping, non-contiguous, and (except for the case of a single range) have non-zero-length.

## See Also

[`selectedRange`](/documentation/AppKit/NSTextInput/selectedRange)

Returns the range of selected text.



---

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)