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 trialMichael Zaro
13,196 PointsI am getting crashes on my code and the code downloaded from the course downloads section. What's up?
In the Grand Central Dispatch section of the Stormy app we run the app. Mine does not display the correct information from the API even though I am getting draws from the darksky API. My available calls number is going down, so I see that I it is at least calling the API.
The crash seems to be coming from the view controller, but I even get crashes from the downloaded code. Any advice. Here is my code, for the sake of comparison.
""" // // ViewController.swift // Stormy // // Created by James Plauche on 9/1/15. // Copyright (c) 2015 Tanner PlauchΓ©. All rights reserved. //
import UIKit
class ViewController: UIViewController { @IBOutlet weak var currentTemperatureLabel: UILabel? @IBOutlet weak var currentHumidityLabel: UILabel? @IBOutlet weak var currentpercipitationLabel: UILabel? private let forecastApiKey = "894454c71c0f2bf41eb5f29c71b0b9ab" let coordinate: (lat: Double, long: Double) = (37.8267,-122.423)
override func viewDidLoad() {
let forecastService = ForecastService(APIKey: forecastApiKey)
forecastService.getForecast(coordinate.lat, long: coordinate.long) {
(let currently) in
if let currentWeather = currently {
//update UI
dispatch_async(dispatch_get_main_queue()){
//execute closure
if let temperature = currentWeather.temperature {
self.currentTemperatureLabel?.text = "\(temperature)ΒΊ"
}
if let humidity = currentWeather.humidity {
self.currentHumidityLabel?.text = "\(humidity)%"
}
if let precipitation = currentWeather.precipProbability {
self.currentpercipitationLabel?.text = "\(precipitation)%"
}
}
}
}
} //end of viewDidLoad
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
"""
1 Answer
Stephen Whitfield
16,771 PointsSo what is the debugger telling you? Look in the console when the app crashes and paste it here. Make sure you are connecting the outlets in your .xib/storyboard file correctly. Also, go ahead and throw super.viewDidLoad() in your subclass of UIViewController before writing all of that code.
Antonija Pek
5,819 PointsAntonija Pek
5,819 PointsWell I assume you have updated your Xcode (to version 7) as I am so this videos are obsolete, and there aren't new ones. Yet. But I am not paying to wait so I guess many people will pause their subscription until they fix this huge problem.