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

Cleaning Up Our Date - Build a Simple Weather app

I am getting an error message for currentTime = dateStringFromUnixtime saying that it contains an unresolved identifier. Also, "currentTime" does not show up in blue as it should. Can anyone please help? I followed Pasan's code to the letter so it should work. Can anyone help? Thanks.

struct Current {

    var currentTime: String?
    var temperature: Int
    var humudity: Double
    var preciProbability: Double
    var summary: String
    var icon: String


    init(weatherDictionary: NSDictionary) {
        let currentWeather = weatherDictionary["currently"] as
           NSDictionary



        temperature = currentWeather["temperature"] as Int
        humudity = currentWeather["humidity"] as Double
        preciProbability = currentWeather["precipProbability"] as Double
        summary = currentWeather["summary"] as String
        icon = currentWeather["icon"] as String

        let currentTimeIntValue = currentWeather["time"] as Int
        currentTime = dateStringFromUnixtime
        (currentTimeIntValue)

}
    func dateStringFromUnixTime(unixTime: Int) -> String  {
        let timeInSeconds = NSTimeInterval(unixTime)
        let weatherDate = NSDate(timeIntervalSince1970:timeInSeconds)
        let dateFormatter = NSDateFormatter()
        dateFormatter.timeStyle = .ShortStyle

        return dateFormatter.stringFromDate(weatherDate)

    }



}

1 Answer

The reason why you are getting that error is because you forgot to add a capital T in dateStringFromUnixTime. Everything should run fine after you change that little mistake :)

currentTime = dateStringFromUnixTime(currentTimeIntValue)

Hope this helped,

Ozzie

Thank you kirkbyo! It worked I think.