---
title: "formatted(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/personnamecomponents/formatted(_:)"
---

# formatted(_:)

Generates a locale-aware string representation of an instance of person name components using the provided format style.

## Declaration

```swift
func formatted<S>(_ style: S) -> S.FormatOutput where S : FormatStyle, S.FormatInput == PersonNameComponents
```

## Parameters

- `style`: Specifies the doc://com.apple.foundation/documentation/Foundation/PersonNameComponents/FormatStyle applied to the person name components.

## Return Value

Return Value A string, formatted according to the provided style.

## Discussion

Discussion Use the formatted(_:) method to create a string representation of a person’s name with a customized length for specific uses. You can use the PersonNameComponents.FormatStyle static factory method name(style:) to create a custom format style as a parameter to the method. For example: var tlc = PersonNameComponents() tlc.familyName = "Clark" tlc.givenName = "Thomas" tlc.middleName = "Louis" tlc.namePrefix = "Dr." tlc.nickname = "Tom" tlc.nameSuffix = "Esq."

tlc.formatted(.name(style: .long)) // Dr. Thomas Louis Clark Esq.

tlc.formatted(.name(style: .medium)) // Thomas Clark

tlc.formatted(.name(style: .short)) // Tom

tlc.formatted(.name(style: .abbreviated)) // TC

## See Also

### Formatting Person Name Components

- [formatted()](foundation/personnamecomponents/formatted().md)
- [PersonNameComponents.FormatStyle](foundation/personnamecomponents/formatstyle.md)
