Swift - Split string over multiple lines

前端 未结 15 2033
清酒与你
清酒与你 2020-12-04 07:51

How could I split a string over multiple lines such as below?

var text:String = \"This is some text
                   over multiple lines\"
15条回答
  •  死守一世寂寞
    2020-12-04 08:29

    Swift:

    @connor is the right answer, but if you want to add lines in a print statement what you are looking for is \n and/or \r, these are called Escape Sequences or Escaped Characters, this is a link to Apple documentation on the topic..

    Example:

    print("First line\nSecond Line\rThirdLine...")
    

提交回复
热议问题