Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Weather App with Swift (Retired) Pulling Data From the Web Fetching JSON Data

Lei zheng
Lei zheng
7,990 Points

NSData.getDatafromURL(...........) now change to NSdata(contentsOfURL: courseURL!, options: nil, error: nil)

this quiz I can not get pass.

students_code.swift
import Foundation
let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")
let courseURL = NSURL(string: "/course/\(courseID)", relativeToURL: treehouseBaseURL)
let courseData: NSData = NSData(contentsOfURL:courseURL!, options : nil, error : nil) as NSData

Try

let courseData  = NSData(contentsOfURL: courseURL!, options: nil , error: nil)

3 Answers

Chris Shaw
Chris Shaw
26,650 Points

Hi Lei zheng,

Your answer is almost correct, the reason it doesn't pass is because the challenge isn't looking for an explicit type to be set for courseData nor do you need to down cast it as an NSData instance as it's already an instance of NSData.

let courseData = NSData(contentsOfURL: courseURL!, options: nil, error: nil)

Happy coding!

Chris your beating me to all the post lol. Good job man :)

Chris Shaw
Chris Shaw
26,650 Points

:stuck_out_tongue_winking_eye: Time for lunch, the throne is all yours :smiley:

Lei zheng
Lei zheng
7,990 Points

thank you both. I copy and paste. it works. I remember I used the same code. including the courseURL! the bang mark there. But I don't know where I get wrong. You guys are awesome. But by the way, why you guys come back answer my question? are you guys paid?

or just to get high point?

I do it because, other MODs did the same for me when I started out at treehouse. I'm glad to return the favor. Im sure sometime in the near future Lei you will become a MOD too.

P.S we don't get paid in cash but we do take Karma points :)

Lei zheng
Lei zheng
7,990 Points

got it. Yes, I will. I am on my way to that MOD position. I just wonder why codeschool did not get much traciton like treehouse forum. I basically a paid member on all the online course. But get most help from stackoverflow, dash and treehouse. thank you again. I love the word karma points. I will try to get some in near future.