---
title: "destinationSelection(for:direction:destination:extending:confined:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextselectionnavigation/destinationselection(for:direction:destination:extending:confined:)"
---

# destinationSelection(for:direction:destination:extending:confined:)

Returns a new selection that results from applying the navigation operations you specify to the text selection you provide.

## Declaration

```swift
func destinationSelection(for textSelection: NSTextSelection, direction: NSTextSelectionNavigation.Direction, destination: NSTextSelectionNavigation.Destination, extending: Bool, confined: Bool) -> NSTextSelection?
```

## Parameters

- `textSelection`: The source selection.
- `direction`: One of the available doc://com.apple.uikit/documentation/UIKit/NSTextSelectionNavigation/Direction directions.
- `destination`: One of the available doc://com.apple.uikit/documentation/UIKit/NSTextSelectionNavigation/Destination destinations.
- `extending`: Whether this selection extends an existing selection.
- `confined`: Whether to confine movement to the existing selection.

## Return Value

Return Value A new NSTextSelection, or nil if the operation doesn’t produce a logically valid result.

## Discussion

Discussion If confined is true, confine any movement to the text element that the selection already lies within.

## See Also

### Working with text selections

- [textSelection(for:enclosing:)](uikit/nstextselectionnavigation/textselection(for:enclosing:).md)
- [textSelections(interactingAt:inContainerAt:anchors:modifiers:selecting:bounds:)](uikit/nstextselectionnavigation/textselections(interactingat:incontainerat:anchors:modifiers:selecting:bounds:).md)
