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 Build a Weather App with Swift (Retired) Data Modeling With Structures Cleaning Up Our Date

Patrick Li
Patrick Li
2,434 Points

unresolved identifier

import Foundation

struct Current{ var currentTime: String? var temperature: Int var humidity: Double var precipProbability: Double var summary: String var icon: String

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

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

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

func dataStringFromUnixtime(uinixTime: Int) -> String{
    let timeInSeconds = NSTimeInterval(unixTime)
    let weatherDate = NSDate(timeIntervalSince1970: timeInSeconds)

    let dateFormatter = NSDateFormatter()
    dateFormatter.timeStyle = .ShortStyle

    return dateFormatter.stringFromDate(weatherDate)
}

}

1 Answer

Stone Preston
Stone Preston
42,016 Points

you mispelled unixTime in your parameter name:

 func dataStringFromUnixtime(uinixTime: Int) -> String{

it should be

 func dataStringFromUnixtime(unixTime: Int) -> String{
Patrick Li
Patrick Li
2,434 Points

thanks! Took forever on it