One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

LocalizedStringKey.StringInterpolation

struct · iOS 13.0+ · SDK 27.1

struct StringInterpolation

Represents the contents of a string literal with interpolations while it’s being built, for use in creating a localized string key.

Members (17)

method · iOS 16.0+

appendInterpolation

TypeScript
appendInterpolationTimerIntervalPauseTimeCountsDownShowsHours(timerInterval: SDKHandle, pauseTime?: (globalThis.Date) | null, countsDown?: boolean, showsHours?: boolean): void
Swift declaration
mutating func appendInterpolation(timerInterval: ClosedRange<Date>, pauseTime: Date? = nil, countsDown: Bool = true, showsHours: Bool = true)

Appends a timer interval to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - timerInterval: The interval between where to run the timer. - pauseTime: If present, the date at which to pause the timer. The default is `nil` which indicates to never pause. - countsDown: Whether to count up or down. The default is `true`. - showsHours: Whether to include an hours component if there are more than 60 minutes left on the timer. The default is `true`.

method · iOS 18.0+

appendInterpolation

TypeScript
appendInterpolationAccessibilityName(color: Color): void
Swift declaration
mutating func appendInterpolation(accessibilityName color: Color)

Appends a localized description of a color for accessibility to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - color: the color being described.

method · iOS 14.0+

appendInterpolation

TypeScript
appendInterpolationStyle(date: globalThis.Date, style: Text_DateStyle): void
Swift declaration
mutating func appendInterpolation(_ date: Date, style: Text.DateStyle)

Appends a formatted date to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - date: The date to append. - style: A predefined style to format the date with.

method · iOS 13.0+

appendInterpolation

TypeScript
appendInterpolationFormatter(subject: ArrayBuffer, formatter?: (_Foundation_Formatter) | null): void
Swift declaration
mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : ReferenceConvertible

Appends an optionally-formatted instance of a Foundation type to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - subject: The Foundation object to append. - formatter: A formatter to convert `subject` to a string representation.

method · iOS 13.0+

appendInterpolation

TypeScript
appendInterpolationFormatter28845(subject: _ObjectiveC_NSObject, formatter?: (_Foundation_Formatter) | null): void
Swift declaration
mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : NSObject

Appends an optionally-formatted instance of an Objective-C subclass to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. The following example shows how to use a <doc://com.apple.documentation/documentation/Foundation/Measurement> value and a <doc://com.apple.documentation/documentation/Foundation/MeasurementFormatter> to create a ``LocalizedStringKey`` that uses the formatter style <doc://com.apple.documentation/documentation/foundation/Formatter/UnitStyle/long> when generating the measurement's string representation. Rather than calling `appendInterpolation(_:formatter)` directly, the code gets the formatting behavior implicitly by using the `\()` string interpolation syntax. let siResistance = Measurement(value: 640, unit: UnitElectricResistance.ohms) let formatter = MeasurementFormatter() formatter.unitStyle = .long let key = LocalizedStringKey ("Resistance: \(siResistance, formatter: formatter)") let text1 = Text(key) // Text contains "Resistance: 640 ohms" - Parameters: - subject: An <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class> to append. - formatter: A formatter to convert `subject` to a string representation.

method · iOS 15.0+

appendInterpolation

TypeScript
appendInterpolation(attributedString: _Foundation_AttributedString): void
Swift declaration
mutating func appendInterpolation(_ attributedString: AttributedString)

Appends an attributed string to a string interpolation. 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 an <doc://com.apple.documentation/documentation/Foundation/AttributedString> and append it to static text. The resulting interpolation implicitly creates a ``LocalizedStringKey``, which a ``Text`` view uses to provide its content. struct ContentView: View { var nextDate: AttributedString { var result = Calendar.current .nextWeekend(startingAfter: Date.now)! .start .formatted( .dateTime .month(.wide) .day() .attributed ) result.backgroundColor = .green result.foregroundColor = .white return result } var body: some View { Text("Our next catch-up is on \(nextDate)!") } } For this example, assume that the app runs on a device set to a Russian locale, and has the following entry in a Russian-localized `Localizable.strings` file: "Our next catch-up is on %@!" = "Наша следующая встреча состоится %@!"; The attributed string `nextDate` replaces the format specifier `%@`, maintaining its color and date-formatting attributes, when the ``Text`` view renders its contents: ![A text view with Russian text, ending with a date that uses white text on a green background.](LocalizedStringKey-AttributedString-Russian) - Parameter attributedString: The attributed string to append.

method · iOS 16.0+

appendInterpolation

TypeScript
appendInterpolation10481(resource: _Foundation_LocalizedStringResource): void
Swift declaration
mutating func appendInterpolation(_ resource: LocalizedStringResource)

Appends the localized string resource to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - resource: The localized string resource to append.

method · iOS 14.0+

appendInterpolation

TypeScript
appendInterpolation77286(interval: _Foundation_DateInterval): void
Swift declaration
mutating func appendInterpolation(_ interval: DateInterval)

Appends a date interval to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameter interval: The date interval to append.

method · iOS 15.0+

appendInterpolation

TypeScript
appendInterpolation22549(attributedSubstring: _Foundation_AttributedSubstring): void
Swift declaration
@export(implementation) mutating func appendInterpolation(_ attributedSubstring: AttributedSubstring)

Appends an attributed substring to a string interpolation. 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 an <doc://com.apple.documentation/documentation/Foundation/AttributedSubstring> and append it to static text. The resulting interpolation implicitly creates a ``LocalizedStringKey``, which a ``Text`` view uses to provide its content. struct ContentView: View { var identificationNumberSuffix: AttributedSubstring { // … } var body: some View { Text("Identification: •••• •••• \(identificationNumberSuffix)!") } } For this example, assume that the app runs on a device set to a Russian locale, and has the following entry in a Russian-localized `Localizable.strings` file: "Identification: •••• •••• %@" = "Идентификация: •••• •••• %@"; The attributed string `identificationNumberSuffix` replaces the format specifier `%@`, maintaining its color attributes, when the ``Text`` view renders its contents: - Parameter attributedSubstring: The attributed substring to append.

method · iOS 14.0+

appendInterpolation

TypeScript
appendInterpolation32465(text: Text): void
Swift declaration
mutating func appendInterpolation(_ text: Text)

Appends the string displayed by a text view to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - text: A ``Text`` instance to append.

method · iOS 14.0+

appendInterpolation

TypeScript
appendInterpolation17910(image: Image): void
Swift declaration
mutating func appendInterpolation(_ image: Image)

Appends an image to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameter image: The image to append.

method · iOS 14.0+

appendInterpolation

TypeScript
appendInterpolation56635(dates: SDKHandle): void
Swift declaration
mutating func appendInterpolation(_ dates: ClosedRange<Date>)

Appends a date range to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameter dates: The closed range of dates to append.

method · iOS 13.0+

appendInterpolation

TypeScript
appendInterpolation13844(string: string): void
Swift declaration
mutating func appendInterpolation(_ string: String)

Appends a literal string segment to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameter string: The literal string to append.

method · iOS 13.0+

appendInterpolation

TypeScript
appendInterpolation91284(substring: string): void
Swift declaration
@export(implementation) mutating func appendInterpolation(_ substring: Substring)

Appends a literal string segment to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameter substring: The interpolated substring to append.

method · iOS 13.0+

appendInterpolation

TypeScript
appendInterpolation73634(object: unknown): void
Swift declaration
@export(implementation) mutating func appendInterpolation<T>(_ object: T)

Appends a type, convertible to a string by using a default format specifier, to a string interpolation. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameters: - value: A primitive type to append, such as <doc://com.apple.documentation/documentation/swift/Int>, <doc://com.apple.documentation/documentation/swift/UInt32>, or <doc://com.apple.documentation/documentation/swift/Double>.

method · iOS 13.0+

appendLiteral

TypeScript
appendLiteral(literal: string): void
Swift declaration
mutating func appendLiteral(_ literal: String)

Appends a literal string. Don't call this method directly; it's used by the compiler when interpreting string interpolations. - Parameter literal: The literal string to append.

init · iOS 13.0+

init

TypeScript
static init(literalCapacity: number, interpolationCount: number): LocalizedStringKey_StringInterpolation
Swift declaration
init(literalCapacity: Int, interpolationCount: Int)

Creates an empty instance ready to be filled with string literal content. Don't call this initializer directly. Instead, initialize a variable or constant using a string literal with interpolated expressions. Swift passes this initializer a pair of arguments specifying the size of the literal segments and the number of interpolated segments. Use this information to estimate the amount of storage you will need. - Parameter literalCapacity: The approximate size of all literal segments combined. This is meant to be passed to `String.reserveCapacity(_:)`; it may be slightly larger or smaller than the sum of the counts of each literal segment. - Parameter interpolationCount: The number of interpolations which will be appended. Use this value to estimate how much additional capacity will be needed for the interpolated segments.

Skipped declarations

6 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

LocalizedStringKey.StringInterpolation.appendInterpolation(_:format:)

This declaration needs Swift generic type arguments. (no canonical witness for F)

LocalizedStringKey.StringInterpolation.appendInterpolation(_:format:)

This declaration needs Swift generic type arguments. (no canonical witness for F)

LocalizedStringKey.StringInterpolation.appendInterpolation(_:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

LocalizedStringKey.StringInterpolation.appendInterpolation(_:specifier:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

LocalizedStringKey.StringInterpolation.appendInterpolation(_:format:)

This declaration needs Swift generic type arguments. (no canonical witness for F)

LocalizedStringKey.StringInterpolation.appendInterpolation(_:format:)

This declaration needs Swift generic type arguments. (no canonical witness for F)

All SwiftUICore types →