Avatar ·

How to create a multiline string in Swift? Problems with line breaks and escaping

Hello everyone! I'm new to Swift and encountered a problem when creating long strings. I need to save text with multiple lines (for example, an address or product description), but regular quoted strings don't work — the compiler complains about line breaks.\n\nHere's what I tried:\n\n```swift\nlet address = "ул. Ленина, д. 10\nкв. 5\nг. Москва"\n```\n\nXcode gives an error: "Unterminated string literal". I understand that in Swift you can't just break a line inside quotes. But how do you write multiline text then? I tried adding `` — it works, but the code becomes unreadable, especially if there are many lines.\n\nI also heard about some "raw strings" and triple quotes `"""`, but I'm not sure how to use them correctly. For example, if the text contains quotes or backslashes — they break the string.