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 trialAustin Rau
Courses Plus Student 3,214 PointsHelp with Weather App (Swift)
Challenge task 2 of 2 first code challenge, please help!
2 Answers
Stone Preston
42,016 Pointsyou need to use string interpolation to interpolate the course ID onto the end of the string.
since the full url used to access a course looks something like "https://api.teamtreehouse.com/course/COURSE_ID", you can see that /course/COURSE_ID is the part of the url thats going to be relative to the base URL, which is "https://api.teamtreehouse.com/".
so interpolate the value of courseID onto the end of the string "course/" and use that as the string parameter.
import Foundation
let courseID = 25
let treehouseBaseURL = NSURL(string:"https://api.teamtreehouse.com/");
let courseURL = NSURL(string: "course/\(courseID)", relativeToURL: treehouseBaseURL);
I found this challenge to be particularly challenging as it does not give you much direction, but after playing with it a while I figured out what they wanted
Austin Rau
Courses Plus Student 3,214 PointsThank you! I had to put "let courseID = 25" before my other constants for it to compile properaly :)