user5334340
user5334340

Reputation:

Split string across different lines Swift 2.0

I'm using the code below print("List:\n 1 \t Apple\n 2 \t Bananas\n 6 \t Oranges", terminator: "") to produce a list that begins a new line with each number

however it just prints "List:\n 1 Apple\n 2 Bananas\n 6 Oranges"

in swift 1.2 it works fine, but in Swift 2.0 it just won't recognise the "\n", anyone know how to spit the string across different lines? or what replaces the \n in swift 2.0?

I know this is basic, but that small issue will cause problems in the future if i can't split a string across lines

Thanks in advance :)

Upvotes: 0

Views: 240

Answers (1)

Eric Aya
Eric Aya

Reputation: 70098

If you're using an Xcode Playground, what you see besides your code is the live panel where values are shown when possible. In your case it will show the argument that was passed to print, which is the literal string. This is not the same as the console output, which will print the formatted string.

In Xcode 7 Playgrounds the console output can be found in:

Menu View > Debug Area > Activate Console

Note: this was previously in "Assistant Editor" in Xcode 6's Playgrounds.

Upvotes: 1

Related Questions