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 Network Programming with Swift 2 Modeling Forecast Data Stubbing the Data

Why's this occurring? "terminating with uncaught exception of type NSException".

Please let me know what i've done wrong. I've followed along inline with the course tutorials. As soon as I attempt to run my app the following line of code is highlighted red within the AppDelegate.swift:

 class AppDelegate: UIResponder, UIApplicationDelegate {

Also, the following error reads in the console: "terminating with uncaught exception of type NSException (lldb)"

The app was working fine before I entered code into ViewController.swift

 import UIKit

 extension CurrentWeather {
 var temperatureString: String {
 return "\(Int(temperature))ΒΊ"
 }


 class ViewController: UIViewController {

@IBOutlet weak var currentTemperatureLabel: UILabel!
@IBOutlet weak var currentHumidityLabel: UILabel!
@IBOutlet weak var currentPrecipitationLabel: UILabel!
@IBOutlet weak var currentWeatherIcon: UIImageView!
@IBOutlet weak var currentSummaryLabel: UILabel!
@IBOutlet weak var refreshButton: UIButton!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!


    override func viewDidLoad() {
    super.viewDidLoad()

    let icon = WeatherIcon.PartlyCloudyDay.image
    let currentWeather = CurrentWeather(temperature: 56.0, humidity: 1.0, precipitationProbability: 1.0, summary: "Wet and rainy!", icon: icon)

    display(weather: currentWeather)
}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func display(weather: CurrentWeather){
 currentTemperatureLabel.text = weather.temperatureString
}
}
}

There may be a more descriptive error if you scroll up in the console. Is there anything above the slew numbers?

Hi Ian Han, thank you for your prompt response. Is this what you mean?

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController     0x7f8341d05740> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key activityIndicator.'
*** First throw call stack:

1 Answer

The answer in your console log is the line: "this class is not key value coding-compliant for the key activityIndicator."

Go back to IB and check to make sure activityIndicator is hooked up properly. Generally that is the issue when you have that error message.

Ian Han, everything appears to be okay. I don't know if it has anything to do with my updating Xcode to Swift 3.0?

Shouldn't be. Here are some options to try. Alternatively, you can shoot me the project at ihan616@gmail.com and I can take a look.

Thanks Ian Han, everything seemed to be okay until I tampered with the following line of code:

       func display(weather: CurrentWeather){
      currentTemperatureLabel.text = weather.temperatureString

I've emailed you the project Ian. Thank you so much for your help.