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 trialJohn Johnjohn
54 PointsUnable to gather weather Data
My application keeps on giving me an error that says "Could not construct a valid URL". does any one know how to fix this. This is my code:
let forecastService = ForecastService(APIKey: forecastAPIKey)
forecastService.getForecast(coordinate.lat, long: coordinate.long) {
(let currently) in
if let currentWeather = currently {
dispatch_async(dispatch_get_main_queue()) {
if let temperature = currentWeather.temperature {
self.currentTemperatureLabel?.text = "\(temperature)ΒΊ"
}
if let humidity = currentWeather.humidity {
self.currentHumidityLabel?.text = "\(humidity)%"
}
if let precipitation = currentWeather.precipProbability {
self.currentPrecipitationLabel?.text = "\(precipitation)"
}
}
}
}
2 Answers
Tommy Choe
38,156 PointsHey John, I'm not sure if I'll be able to answer your question but my advice would be to just check your coordinates in the ViewController file. I messed up earlier because I didn't add a forward slash after my API key.
Let me know what happens.
Lee Adamson
9,347 PointsTommy Choe i did this exact same thing with the trailing slash, spent ages looking through the code to find this.