<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextContentManager/textElements(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextContentManager(im)textElementsForRange:"
  },
  "title" : "textElements(for:)"
}
-->

# textElements(for:)

Returns an array of text elements that intersect with the range you specify.

```
func textElements(for range: NSTextRange) -> [NSTextElement]
```

## Parameters

`range`

An [`NSTextRange`](/documentation/AppKit/NSTextRange) that describes the range of text to process.

## Return Value

An array of [`NSTextElement`](/documentation/AppKit/NSTextElement).

## Discussion

This method can return a set of elements that don’t fill the entire range if the entire range isn’t synchronously available. Uses [`enumerateTextElements(from:options:using:)`](/documentation/AppKit/NSTextElementProvider/enumerateTextElements(from:options:using:)) to fill the array.

---

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)