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
Edwin Mhoy Silva Rifa2,631 Points
don´t really know what to do??
At Treehouse we have our own API which can be accessed via a base URL that looks like: https://api.teamtreehouse.com/. Create a base URL named treehouseBaseURL using the NSURL class to retrieve user information from the Treehouse API. Note: This is purely an example and not a functional API.
import Foundation let courseID = 25 let treehouseBaseURL = "https://api.teamtreehouse.com/"
Stone Preston42,016 Points
Task 1 states: ** Create a base URL named treehouseBaseURL using the NSURL class to retrieve user information from the Treehouse API**
so for task 1 you need to create a URL using the NSURL initializer and pass in the base URL:
let treehouseBaseURL = NSURL(string:"https://api.teamtreehouse.com/");
task 2 states: ** 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.**
you 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);