---
title: "enumerateSubstrings(from:options:using:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextselectiondatasource/enumeratesubstrings(from:options:using:)"
---

# enumerateSubstrings(from:options:using:)

Enumerates the textual segment boundaries starting at the location you specify.

## Declaration

```swift
func enumerateSubstrings(from location: any NSTextLocation, options: NSString.EnumerationOptions = [], using block: (String?, NSTextRange, NSTextRange?, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

- `location`: The location where the enumeration starts.
- `options`: One or more of the available doc://com.apple.documentation/documentation/Foundation/NSString/EnumerationOptions.
- `block`: A closure to invoke to evaluate the substrings; end the enumeration early by returning false.

## Discussion

Discussion

## See Also

### 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)
