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 trialLevi Lais
5,975 PointsLet's assume that the courseURL we created earlier returns some JSON data from Treehouse API. Create a data object to ca
In this challenge, it's saying that I need to use something called the "dataWithContentsOfURL method" - which I've never heard of. As far as I understand it, this should be the answer according to what we were taught:
let courseData = NSData(contentsOfURL: courseURL)
However, Swift's NSData syntax must be different now - because the way the video shows us how to do it doesn't work in my version of Xcode. I had to alter the code so that it would work. I narrowed it down to an issue with splitting out the baseURL from the main URL. I consolidated the 2 and was able to return data in the app. I think that perhaps the problem with this "Challenge task" is that it's asking me to do it the wrong way again - and the solution is failing on the backend. However, I could be wrong - so if someone has the solution to this challenge, I'd love to see it.
2 Answers
Chris Shaw
26,676 PointsHi Levi,
Pasan introduced the dataWithContentsOfURL
method in the Making a Network Call video which is before the challenge and gives it context, in this challenge it's the correct technique to use as so far the course hasn't covered the contentsOfURL
constructor for NSURL
.
Justin VanHaven
2,135 Points"Making a Network Call" is a frustrating lesson because all the coding he does is behind the video player bar on the bottom of the screen.