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 trialRamesh VJ
2,201 PointsI'm getting runtime error in currentTemperatureLabel
I'm getting runtime error in currentTemperatureLabel
@IBOutlet weak var currentTemperatureLabel: UILabel? I tried ! also @IBOutlet weak var currentTemperatureLabel: UILabel!
I tried without if let option too
let plistPath = NSBundle.mainBundle().pathForResource("CurrentWeather", ofType: "plist") let weatherDictionary = NSDictionary(contentsOfFile: plistPath!) let currentWeatherDictionary = weatherDictionary!["currently"] as? [String: AnyObject]
let currentWeather = CurrentWeather(weatherDictionary: currentWeatherDictionary!)
currentTemperatureLabel?.text = "\(currentWeather.temperature)"
nothing seems to be working.
Please help
Tal Zion
6,234 PointsI am not sure why you wrote it like that but this should work now:
let plistPath = NSBundle.mainBundle().pathForResource("CurrentWeather", ofType: "plist"), let weatherDictionary = NSDictionary(contentsOfFile: plistPath), let currentWeatherDictionary = weatherDictionary["currently"] as? [String: AnyObject]{ let currentWeather = CurrentWeather(weatherDictionary: currentWeatherDictionary) currentTemperatureLabel?.text = "(currentWeather.temperature)" }
Ramesh VJ
2,201 PointsRamesh VJ
2,201 PointsI'm not getting the label in the simulator. I'm using Xcode 7