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

iOS Build a Weather App with Swift (Retired) Pulling Data From the Web JavaScript Object Notation

CHRISTOPHER RUNCO
CHRISTOPHER RUNCO
2,165 Points

JSON in playground not working...tried all previous suggestions

I have looked through the questions about the JSON data not coming up in the playground and I have tried every option people suggested with no avail. let apiKey = "xxx"

let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/") let forecastURL = NSURL(string: "40.678840,-73.948774", relativeToURL: baseURL)

-----provides a popup of a image of safari let apiKey = "xxx"

let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/") let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL) let weather = NSData(contentsOfURL: forecastURL!, options: nil, error: nil) let string = NSString(data: weather!, encoding: NSUTF8StringEncoding)

------provides a nil value on line "let weather" and safari image on other lines

let apiKey = "xxx"

let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/") let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL) let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil) println(weatherData!)

-------same

no matter what i try i do not get a JSON value....Please help!