---
title: "textElement(for:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextcontentstorage/textelement(for:)"
---

# textElement(for:)

Returns the text element corresponding to object’s attributed string.

## Declaration

```swift
func textElement(for attributedString: NSAttributedString) -> NSTextElement?
```

## Parameters

- `attributedString`: The attributed string to map into an doc://com.apple.uikit/documentation/UIKit/NSTextElement.

## Return Value

Return Value An NSTextElement, or nil.

## Discussion

Discussion Returns nil when attributedString contains attributes not mappable to NSTextElement.

## See Also

### Managing text elements

- [attributedString(for:)](uikit/nstextcontentstorage/attributedstring(for:).md)
