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!

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 (Retired) Pulling Data From the Web Networking in iOS

Juran-Perez Moodley
Juran-Perez Moodley
2,018 Points

Need help on task 2 in the challenges. My code isn't working.

import Foundation

let courseID = "https://api.teamtreehouse.com/course/COURSE_ID"

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

let courseURL = NSURL(string: "(courseID)", relativeToURL: treehouseBaseURL)

1 Answer


There's a few points to this challenge. First, you need to make the treehouseBaseURL which you've already done.

Then you need to create a relative URL based on the given courseID and a slightly modified URL. You need to append "course/" to the base URL and then ID at the end of it. You can do that with String Interpolation, "course/\(courseID)" is the correct suffix to add to the existing URL.

You end up with:

let courseID = 25
let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")
let courseURL = NSURL(string: "course/\(courseID)" , relativeToURL:treehouseBaseURL)

That should get you through the challenge.