The person name components object to format.
Instance Method
インスタンスメソッド
format(_:)
Creates a string representation from a person name components value.
Availability 有効性
- iOS 15.0+
- iPadOS 15.0+
- macOS 12.0+
- Mac Catalyst 15.0+
- tvOS 15.0+
- watchOS 8.0+
- Xcode 13.0+
Technology
- Foundation ファウンデーション
Declaration 宣言
func format(_ value: PersonNameComponents
) -> String
Parameters パラメータ
value
Return Value 戻り値
A string representation of the person name components.
Discussion 議論
The format(_:)
instance method applies the style to an instance of Person
. 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