Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to wrap a long string in Xcode to new line?

Tags:

xcode

swift

I have word-wrapping disabled in Xcode and I try to limit every line to 120 characters. But what can I do when I have a really long string that breaks this limit? I can't find a clean way to wrap it to a new line in Xcode without creating multiple strings.

like image 881
kidcoder SAVE UKRAINE Avatar asked Dec 05 '25 06:12

kidcoder SAVE UKRAINE


1 Answers

Since you are using the Swift tag, I'll assume you're programming in swift.

Swift supports multiline strings like this:

var about: String = """
My name is Adam.
I am a software developer.
"""

This will include a newline character at the end of each line. To remove the newline character add a \ to the end of the line.

Example:

var about: String = """
My name is Adam. \
I am a software developer.
"""

Swift Reference for Multiline Strings

like image 122
Adam Comer Avatar answered Dec 07 '25 03:12

Adam Comer