format(_:)
Creates a string representation from a person name components value.
Declaration
func format(_ value: PersonNameComponents) -> StringParameters
- value:
The person name components object to format.
Return Value
A string representation of the person name components.
Discussion
The format(_:) instance method applies the style to an instance of PersonNameComponent. After creating a style, you can use it to format multiple instances of person name components. For example:
let customPersonFormatStyle = PersonNameComponents.FormatStyle(style: .medium, locale: Locale(identifier: "us_EN"))
var person1 = PersonNameComponents()
person1.familyName = "Clark"
person1.givenName = "Thomas"
person1.middleName = "Louis"
person1.namePrefix = "Dr."
person1.nickname = "Tom"
person1.nameSuffix = "Esq."
let customPersonString1 =
customPersonFormatStyle.format(person1)
// Thomas Clark
let customPersonString2 =
customPersonFormatStyle.format(person2)
// Maria Ruiz