Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics (retired) Types Strings

Using Xcode 7, putting a \n in the middle of a string no longer moves the rest to a new line, it just prints the \n

In Xcode 7 putting \n in the middle of a string no longer moves the text that follows to a new line, it just prints the \n as if it were part of the string, how can his be overcome?

4 Answers

There are quite a few changes, string interpolation being one of them. print() now adds a newline (unless you use the optional appendNewline: false command).

I think this is still in Beta at the moment? Stable releases remain as Xcode 6.

I'll see if I can dig out a list of changes and post back.

Steve.

Its in gold master state at the moment, and yeah i've got that part figured out, but the tutorial is telling me to type print("List:\n 1 - Apple\n 2 - Bananas\n 6 - Oranges", terminator: "") (the terminator is to stop it printing /n at the end of every line) except it prints the \n as if it were part of the string, i need it to print like this "List: 1 - Apple 2 - Bananas 6 - Oranges" and it prints this "List:\n 1 - Apple\n 2 - Bananas\n 6 - Oranges"

Thanks in Advance

Liam

I've had a trawl through the documentation and the only reference to \n that I could find is of no use to this problem as it is talking about the end of string automatic newline, not one mid-string.

Yeah, I did a quick search through Apple's Swift 2.0 book but found nothing :/

The \n works fine, in short. :-)

I figured out the problem, it was Apple changing the name of the assistant editor, it's all sorted now, thanks :)

can you explain please im so confused