<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/LocalizedStringKey/StringInterpolation/appendInterpolation(_:formatter:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI18LocalizedStringKeyV0D13InterpolationV06appendF0_9formatteryx_So11NSFormatterCSgtSo8NSObjectCRbzlF::OverloadGroup"
  },
  "title" : "appendInterpolation(_:formatter:)"
}
-->

# appendInterpolation(_:formatter:)

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

```
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

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`](/documentation/SwiftUI/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"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)