appendInterpolation(_:format:)
Appends the formatted representation of a nonstring type supported by a corresponding format style.
Declaration
mutating func appendInterpolation<F>(_ input: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == AttributedStringParameters
- input:
The instance to format and append.
- format:
A format style to use when converting
inputinto an attributed string representation.
Discussion
Don’t call this method directly; it’s used by the compiler when interpreting string interpolations.
The following example shows how to use a string interpolation to format a Date with a Date.FormatStyle and append it to static text. The resulting interpolation implicitly creates a LocalizedStringKey, which a Text uses to provide its content.
Text("The time is \(myDate, format: Date.FormatStyle(date: .omitted, time:.complete).attributedStyle)")