---
title: "annotatedString(from:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/personnamecomponentsformatter/annotatedstring(from:)"
---

# annotatedString(from:)

Returns an attributed string formatted for a given NSPersonNameComponents object, with attribute annotations for each component.

## Declaration

```swift
func annotatedString(from components: PersonNameComponents) -> NSAttributedString
```

## Parameters

- `components`: A formatted string representation of the given name components.

## Return Value

Return Value An attributed string representation of the given name components. You can determine the person component corresponding to a particular range of the attributed string by querying the NSPersonNameComponentKey attribute, providing one of the NSPersonNameComponent constant values defined below as the attribute value.

## Discussion

Discussion Use this method to style individual components of a formatted name, such as a name in a label.

## See Also

### Converting Between Person Name Components and Strings

- [localizedString(from:style:options:)](foundation/personnamecomponentsformatter/localizedstring(from:style:options:).md)
- [string(from:)](foundation/personnamecomponentsformatter/string(from:).md)
- [personNameComponents(from:)](foundation/personnamecomponentsformatter/personnamecomponents(from:).md)
- [getObjectValue(_:for:errorDescription:)](foundation/personnamecomponentsformatter/getobjectvalue(_:for:errordescription:).md)
