Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading