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 Build a Weather App with Swift Interacting with Data From the Web Constructing a URL

String interpolation is not working. Getting unknown error.

Line 2 should work but does not.

let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")

let courseURL = NSURL(string: "course/(COURSE_ID)", relativeToURL: treehouseBaseURL)

urls.swift
import Foundation

let treehouseCourseID = 25

// Add your code below
let treehouseBaseURL  = NSURL(string: "https://api.teamtreehouse.com/")
let courseURL = NSURL(string: "course/\(COURSE_ID)", relativeToURL: treehouseBaseURL)

3 Answers

Got it, thanks.

Incidentally, it turned out the instructions were wrong. It was instruction me to use "courseID" as the variable name, but as you see in the code, the variable name is actually "treehouseCourseID".

Greg Kaleka
Greg Kaleka
39,021 Points

Oh interesting - after you complete a challenge, there's a link on the pop-up giving you your points where you can leave feedback. If you run into problems like this one, make sure you leave feedback.

Pasan Premaratne, you may want to have a quick look at this challenge's wording.

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Grant,

There's no variable in your code named COURSE_ID, so Swift has no idea what you want there. If you're trying to pass in treehouseCourseID, you have to use that.

import Foundation

let treehouseCourseID = 25

// Add your code below
let treehouseBaseURL  = NSURL(string: "https://api.teamtreehouse.com/")
let courseURL = NSURL(string: "course/\(treehouseCourseID)", relativeToURL: treehouseBaseURL)

There's no variable in your code named COURSE_ID, so Swift has no idea what you want there. If you're trying to pass in treehouseCourseID, you have to use that.