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

Help: iOS swift development basic/ types; numbers and booleans.

We need store some information about a book in several variables. Let's start with the title of book. Create a constant named title and assign it a string: "A Dance with Dragons".???

Couldn't be a more simple question. Break it down and you should understand it - the example wants you to store the title of a book by:

  • Creating a constant named constant
  • Assign a string "A Dance With Dragons" to the constant

If you cannot complete the code challenge, I suggest you re watch the video or read the swift programming guide. I feel it is more beneficial for you to solve this yourself rather than me post an answer.

Jeff Wilkey
Jeff Wilkey
10,296 Points

I'm with Jayden on this one, you should really just skim over the video again. Except be sure that your constant is named title

as the instructions state.

I appreciate the help. I think the biggest problem I have right now is interpreting what the question is asking me to do. I plan to look over this problem again shortly, hopefully your guidance will be helpful. Thanks

1 Answer

Jhoan Arango
Jhoan Arango
14,575 Points

Hello Hans :

Assigning values to a constant or variable is simple. Think of it as STORING something inside a word, or giving that word a meaning. The first thing the challenge is asking for is:

"We need store some information about a book in several variables. Let's start with the title of book. Create a constant named title and assign it a string: "A Dance with Dragons".???”

You know that a constant starts with the word let, after this you want to give a name to the constant

let name 

In order to give a value to your constant you have to use the equal sign “ = “.

 let name =  

// the equal sign assigns values

Now, after creating a constant, you must give it ITS value. In this case it will be a STRING

let name = This will be the value

I hope this helps you solve your challenge. Now you can go back and give it a try.

Carlos Rubio
Carlos Rubio
497 Points

I'm at the same place in that track. I have rewatched the video. I'm doing exactly what you're saying, I even try it in Xcode and it works. But when I put it on the assignment itself, it comes back wrong (if I click "preview" instead nothings comes up, it's just a blank page).

Jhoan Arango
Jhoan Arango
14,575 Points

Carlos, what is the answer you are giving it ?

Carlos Rubio
Carlos Rubio
497 Points

let tittle = "A Dance with Dragons"

(I also try with: let tittle: String = "A Dance with Dragons" even though that seemed redundant)

Jhoan Arango
Jhoan Arango
14,575 Points

Carlos, I think I have seen where you have your error.. When they ask for a challenge, they are very strict with spelling and case sensitive.

let title = A Dance with Dragons

the problem is “title” instead of “tittle”

Carlos Rubio
Carlos Rubio
497 Points

so my mistake was not on the "swift" language but on the "english" language... fair enough.. lol!

Thank you Jhoan!