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

Jamie Lim
7,783 Pointsweather app keeps returning nil from weatherData
It keeps returning nil for my weatherData.
let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL)
let weatherData = NSData.dataWithContentsOfURL(forecastURL, options: nil, error: nil)
println(weatherData)

Jamie Lim
7,783 PointsYes, I'm using my own api key, but still no luck.

agreatdaytocode
24,757 PointsCan you post the rest of your code for us to look at.
1 Answer

Luis Matute
1,490 Pointstry this instead
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!)
println(weatherData)
NSURL
now returns an optional and needs to be unwrapped.

Philip Williams
8,708 PointsHello,
I have tried this solution but it still returns an error. Has anyone got these lines of code to return anything other than "nil"?
agreatdaytocode
24,757 Pointsagreatdaytocode
24,757 PointsJamie,
Are you using your own API Key? Make sure it's not the one from the video.