<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSTextSelectionNavigation/deletionRanges(for:direction:destination:allowsDecomposition:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextSelectionNavigation(im)deletionRangesForTextSelection:direction:destination:allowsDecomposition:"
  },
  "title" : "deletionRanges(for:direction:destination:allowsDecomposition:)"
}
-->

# deletionRanges(for:direction:destination:allowsDecomposition:)

Returns the ranges for deleting the text based on the current selection and movement arguments.

```
func deletionRanges(for textSelection: NSTextSelection, direction: NSTextSelectionNavigation.Direction, destination: NSTextSelectionNavigation.Destination, allowsDecomposition: Bool) -> [NSTextRange]
```

## Parameters

`textSelection`

The text selection.

`direction`

The [`NSTextSelectionNavigation.Direction`](/documentation/UIKit/NSTextSelectionNavigation/Direction) to consider when calculating the deletion ranges.

`destination`

The [`NSTextSelectionNavigation.Destination`](/documentation/UIKit/NSTextSelectionNavigation/Destination) that describes the scope of the text selection to consider when calculating the deletion ranges.

`allowsDecomposition`

A Boolean value that determines if this method operates on composite characters which may be present depending on the characteristics of the script used by `textSelection`.

## Return Value

An array of text ranges to delete.

## Discussion

The selection after deletion contains a zero-length range starting at the location of the first range returned. The framework ignores the destination when `textSelection` has a non-empty selection. The `allowsDecomposition` parameter only applies to the [`NSTextSelectionNavigation.Direction.backward`](/documentation/UIKit/NSTextSelectionNavigation/Direction/backward) direction and [`NSTextSelectionNavigation.Destination.character`](/documentation/UIKit/NSTextSelectionNavigation/Destination/character) with a zero-length selection.

---

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)