Contents

formatted()

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

Declaration

func formatted() -> String

Return Value

A string, formatted according to the default style.

Discussion

The formatted() method creates a string representation of a person’s name suitable for most uses.

var tlc = PersonNameComponents()
tlc.familyName = "Clark"
tlc.givenName = "Thomas"
tlc.middleName = "Louis"
tlc.namePrefix = "Dr."
tlc.nickname = "Tom"
tlc.nameSuffix = "Esq."

tlc.formatted()
// Thomas Clark

If you want more control over the length and formatting of the name string, consider using the formatted(_:) method and including a format style.

See Also

Formatting Person Name Components