Swift String is a value type with full Unicode support. String interpolation embeds values with \(expression)—cleaner than concatenation or format strings.
Interpolation and multiline
let user = "Ada"
print("Hello, \(user)")
print("Next year: \(2026 + 1)")
let poem = """
Line one
Line two
"""
Common operations
count,isEmpty,hasPrefix,hasSuffixsplit(separator:),replacingOccurrences(of:with:)- Subscript with
String.Index—not integer offsets (Unicode-safe)
Important interview questions and answers
- Q: Why String.Index instead of Int subscripts?
A: Swift strings are Unicode-correct—character boundaries are not fixed-width byte offsets. - Q: String vs NSString?
A: SwiftStringbridges to FoundationNSStringon Apple platforms when importing Objective-C APIs.
Self-check
- How do you embed a variable in a string?
- What delimiter creates a multiline string?
Tip: Use \(expression) for interpolation—not integer subscripts for character access.
Interview prep
- String.Index why?
Unicode-correct strings—character boundaries are not fixed byte offsets.
- Interpolation syntax?
\(expression) embeds values in strings.