<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/StringInterpolationProtocol/init(literalCapacity:interpolationCount:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s27StringInterpolationProtocolP15literalCapacity18interpolationCountxSi_Sitcfc"
  },
  "title" : "init(literalCapacity:interpolationCount:)"
}
-->

# init(literalCapacity:interpolationCount:)

Creates an empty instance ready to be filled with string literal content.

```
init(literalCapacity: Int, interpolationCount: Int)
```

## Parameters

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

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

## Discussion

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.

---

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)