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
Jason Larkin
13,970 PointsPulling Data From the Web Challenge 1 part 2 problems
Hello, I'm stuck on this problem, although I reviewed the preceding video thoroughly, I could find nothing that covered this. The instructions are:
Challenge Task 2 of 2
To access information about a course we can use a URL like: https://api.teamtreehouse.com/course/COURSE_ID. Given the variable courseID, create an absolute URL, named courseURL, to retrieve information about a user's progress on a certain course. It should have a path that's relative to the treehouseBaseURL.
Here is my code:
import Foundation
let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")
var courseID = NSURL(string: "https://api.teamtreehouse.com/course/COURSE_ID", relativeToURL:treehouseBaseURL)
2 Answers
Francisco Navarro
14,185 PointsI put the code to avoid confusion, notice that I've changed the name of the variable in the last sentence
let courseID = 25
let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")
var courseURL = NSURL(string: "https://api.teamtreehouse.com/course/\(courseID)", relativeToURL:treehouseBaseURL)
Francisco Navarro
14,185 PointsHi Jason,
I notice two things:
1) The variable has to be named as courseURL instead of courseID, as courseID is for a sentence you probably have missed:
let courseID = 25
2) It seems like they want you to look for that specific courseID so try to put:
"https://api.teamtreehouse.com/course/\(courseID)" instead of: "https://api.teamtreehouse.com/course/COURSE_ID"
Let me know if that works
Jason Larkin
13,970 PointsThank you Fransisco, but it returns this error message: swift_lint.swift:15:70: error: variable used within its own initial value var courseID = NSURL(string: "https://api.teamtreehouse.com/course/\(courseID)", relativeToURL:treehouseBaseURL)
Jason Larkin
13,970 PointsJason Larkin
13,970 PointsThank you Francisco, it worked finally.