Welcome to the Treehouse Community
Looking to learn something new?
Andy Williams4,436 Points
wetherData is nil
My weatherData constant contains nil. I have checked the URL and APIKey and all is ok. I made sure the Simulator can access the internet by checking Safari.
Not sure what else I can try.
I also ran into the same issue and banged my head up against this for two whole days. I ran this in a playground and found that my error came from a missing forward slash in the base URL.
I figured out this problem by typing each line one by one in the playground. As you create your baseURLs and forcastURLs, the editor will show you the result as you create it.
You should wind up with something like this
import UIKit private let forecastAPIKey = "YOUR API KEY GOES HERE" let baseURL = NSURL (string: "https://api.forecast.io/forecast/\(forecastAPIKey)/") println(baseURL) let forecastURL = NSURL (string: "37.8267,-122.423", relativeToURL: baseURL) // Data object to fetch weather data. NSData performs a network call when used let weatherData = NSData (contentsOfURL: forecastURL!, options: nil, error: nil) println(weatherData)
michael aune2,333 Points
thanks for the assist! duly noted on the attention to detail needed on the URL ;)