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

# attributedString(for:)

Returns a new attributed string for the text element.

## Declaration

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

## Parameters

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

## Return Value

Return Value An NSAttributedString, or nil.

## Discussion

Discussion Returns nil if the method can’t map textElement to an NSAttributedString.

## See Also

### Managing text elements

- [textElement(for:)](uikit/nstextcontentstorage/textelement(for:).md)
