Swift – Double Quotes inside String
To include quotes inside a string in Swift, escape the quote symbol with backslash character, i.e., place a backslash character before the double quote inside the string.
Example
In the following program, we initialized a variable with String value containing double quote. We have escaped the double quote with a backslash character.
main.swift
</>
Copy
import Foundation
var name = "Hello \"World"
print(name)
Output
Hello "World
Conclusion
In this Swift Tutorial, we learned how to include double quotes inside a String value in Swift, with the help of example programs.