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 Printing Results

I'm getting no console output for this line of code: println("To build an iPhone app we need to learn \ (modernProgra

println("To build an iPhone app we need to learn \ (modernProgrammingLanguage)")

Xcode does not like the like break \ and it doesn't allow that line to run on the console

Ghaith Ali
Ghaith Ali
3,134 Points

you seem to have a space between the back slash and the parenthesis.

2 Answers

Hi Brian,

If you are using an updated Xcode (v7 or v7.1) you will be given an error for using println.There should be a red marker to the left of that line of code in Xcode. Clicking that will give you a "fix-it" option of using print instead. Select that option.

Then, as Ghaith has pointed out, you have a space in between your backslash and the opening bracket.

The lines of code should look something like:

var modernProgrammingLanguage = "Swift"
print("To build an app we need to learn \(modernProgrammingLanguage)")

That works fine. The output may not appear in the 'Assistant Editor' as the course envisages. If you go to View | Debug Area and select Show Debug Area, you should see your output in there.

I hope that helps - else shout back.

Steve.

Neither the console nor the Debugger is reconizing my code. It says theres an invalid redeclaration of the var modernProgrammingLanguage. Any ideas?

var str : String = "Hello "

let modernProgrammingLanguage : String = "Objective C" // SRH This is duplicated below

var greeting = "\(str) + \(modernProgrammingLanguage)" // implicit type string or inferred type of String


var modernProgrammingLanguage = "Swift"   // SRH same variable name *declared* a 2nd time.
print("To build an app we need to learn \(modernProgrammingLanguage)")

Yes. You have redeclared the modernProgrammingLanguage variable, just like the playground says.

I don't know what you are trying to achieve here, but if you want the last two lines of code to work, delete the second let statement.

What is it you are trying to complete? Is this a challenge in Treehouse? Which one - let's get the code sorted. I'll add two comments where the current error is coming from in your own code above. But that's just to highlight the current issue.

If you can detail what you are wanting to achieve, I'll get you through that too.