<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextSelectionDataSource/enumerateSubstrings(from:options:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextSelectionDataSource(im)enumerateSubstringsFromLocation:options:usingBlock:"
  },
  "title" : "enumerateSubstrings(from:options:using:)"
}
-->

# enumerateSubstrings(from:options:using:)

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

```
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

---

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)