---
title: NSTextSelectionDataSource
framework: appkit
role: symbol
role_heading: Protocol
path: appkit/nstextselectiondatasource
---

# NSTextSelectionDataSource

A set of methods that objects implement to provide data for, and manage text selections.

## Declaration

```swift
protocol NSTextSelectionDataSource : NSObjectProtocol
```

## Topics

### Range of the selection

- [documentRange](appkit/nstextselectiondatasource/documentrange.md)

### Enumerating components of the selection

- [enumerateCaretOffsetsInLineFragment(at:using:)](appkit/nstextselectiondatasource/enumeratecaretoffsetsinlinefragment(at:using:).md)
- [enumerateContainerBoundaries(from:reverse:using:)](appkit/nstextselectiondatasource/enumeratecontainerboundaries(from:reverse:using:).md)
- [enumerateSubstrings(from:options:using:)](appkit/nstextselectiondatasource/enumeratesubstrings(from:options:using:).md)

### Finding specific content in the selection

- [location(_:offsetBy:)](appkit/nstextselectiondatasource/location(_:offsetby:).md)
- [lineFragmentRange(for:inContainerAt:)](appkit/nstextselectiondatasource/linefragmentrange(for:incontainerat:).md)
- [offset(from:to:)](appkit/nstextselectiondatasource/offset(from:to:).md)
- [textRange(for:enclosing:)](appkit/nstextselectiondatasource/textrange(for:enclosing:).md)

### Changing the characteristics of the selection

- [baseWritingDirection(at:)](appkit/nstextselectiondatasource/basewritingdirection(at:).md)
- [NSTextSelectionNavigation.WritingDirection](appkit/nstextselectionnavigation/writingdirection.md)
- [textLayoutOrientation(at:)](appkit/nstextselectiondatasource/textlayoutorientation(at:).md)
- [NSTextSelectionNavigation.LayoutOrientation](appkit/nstextselectionnavigation/layoutorientation.md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

### Conforming Types

- [NSTextLayoutManager](appkit/nstextlayoutmanager.md)

## See Also

### Accessing the data source

- [textSelectionDataSource](appkit/nstextselectionnavigation/textselectiondatasource.md)
