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

i don't see any error but my time label's don't show up on the weather app

class ViewController: UIViewController {

    var dailyWeather: DailyWeather? {
        didSet {
            configureView()
        }
    }
    @IBOutlet weak var weatherIcon: UIImageView?
    @IBOutlet weak var summaryLabel: UILabel?
    @IBOutlet weak var sunriseTimeLabel: UILabel?
    @IBOutlet weak var sunsetTimeLabel: UILabel?
    @IBOutlet weak var lowTemperatureLabel: UILabel?
    @IBOutlet weak var highTemperatureLabel: UILabel?
    @IBOutlet weak var precipitationLabel: UILabel?
    @IBOutlet weak var humidityLabel: UILabel?

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        configureView()
        }

    func configureView() {
        if let weather = dailyWeather {
            self.title = weather.day
            // Update UI with information from the data model
            weatherIcon?.image = weather.largeIcon
            summaryLabel?.text = weather.summary
            sunriseTimeLabel?.text = weather.sunriseTime
            sunsetTimeLabel?.text = weather.sunsetTime

            if let lowTemp = weather.minTemperature,
               let highTemp = weather.maxTemperature,
               let rain = weather.precipChance,
               let humidity = weather.humidity {
                lowTemperatureLabel?.text = "\(lowTemp)º"
                highTemperatureLabel?.text = "\(highTemp)º"
                precipitationLabel?.text = "\(rain)%"
                humidityLabel?.text = "\(humidity)%"

            }
 }

         // Configure nav Bar back button.
        if let buttonFont = UIFont(name: "HelveticaNeue-Thin", size: 20.0) {
            let barButtonAttributesDictionary: [String: AnyObject]? = [
                NSForegroundColorAttributeName: UIColor.whiteColor(),
                NSFontAttributeName: buttonFont
            ]
            UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAttributesDictionary, forState:             .Normal)
        }
        // Update UI with information from the data model
        weatherIcon?.image

    }

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

}

3 Answers

Nathan Tallack
Nathan Tallack
22,164 Points

It is likely that you have some missing or conflicting constraints in your autolayout. To confirm this you can open your Main Storyboard and open your assistant editor (the two overlapping circles button in the top left) and in the right hand editor pane drop down where it says auto and change it to preview. That gives you a sneak look at your autolayout results.

Also, while in your main storyboard left hand editor pane) you can expand your document outline in your if it is not yet showing (little icon in bottom left) and if there are any problems with your constraints a little red or yellow symbol will show in the top right of that pane. You can click on that to get a list of them and some guidance on how to resolve them.

No i don't have missing constrain or conflicting, and i check the preview and they show mi time label on all screen sizes. I don't know what else to check. Do you have some oder idea that what can be?

I fund the problem, thanks Nathan Tallack.... :)

Nathan Tallack
Nathan Tallack
22,164 Points

Don't leave us in suspense like that. What was it? :)

On the DailyWeather.Swift File i forgot to put the if let statement for sunsetDate.

''' swift

if let sunsetDate = dailyWeatherDict["sunsetTime"] as? Double { sunsetTime = timeStringFromUnixTime(sunsetDate) } else { sunsetTime = nil }

'''

So i just add it and works.