---
title: "appendInterpolation(_:formatter:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/localizedstringkey/stringinterpolation/appendinterpolation(_:formatter:)"
---

# appendInterpolation(_:formatter:)

Appends an optionally-formatted instance of an Objective-C subclass to a string interpolation.

## Declaration

```swift
mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : NSObject
```

## Parameters

- `subject`: An doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class to append.
- `formatter`: A formatter to convert subject to a string representation.

## Discussion

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 Measurement value and a MeasurementFormatter to create a LocalizedStringKey that uses the formatter style 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"

## See Also

### Appending to an interpolation

- [appendInterpolation(_:)](swiftui/localizedstringkey/stringinterpolation/appendinterpolation(_:).md)
- [appendInterpolation(_:specifier:)](swiftui/localizedstringkey/stringinterpolation/appendinterpolation(_:specifier:).md)
- [appendInterpolation(_:format:)](swiftui/localizedstringkey/stringinterpolation/appendinterpolation(_:format:).md)
- [appendInterpolation(_:style:)](swiftui/localizedstringkey/stringinterpolation/appendinterpolation(_:style:).md)
- [appendInterpolation(timerInterval:pauseTime:countsDown:showsHours:)](swiftui/localizedstringkey/stringinterpolation/appendinterpolation(timerinterval:pausetime:countsdown:showshours:).md)
- [appendLiteral(_:)](swiftui/localizedstringkey/stringinterpolation/appendliteral(_:).md)
