---
title: NSTextSelectionDataSource
framework: uikit
role: symbol
role_heading: Protocol
path: uikit/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](uikit/nstextselectiondatasource/documentrange.md)

### Enumerating components of the selection

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

### Finding specific content in the selection

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

### Changing the characteristics of the selection

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

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

### Conforming Types

- [NSTextLayoutManager](uikit/nstextlayoutmanager.md)

## See Also

### Accessing the data source

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