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

Problem with Xcode - Making a Simple Weather app in Swift

Hi, I am getting error messages back from Xcode on the "humidity" and "precipProbability" lines that say that I am using an unresolved identifier in the case of "precip" and that Int is not convertible to Double. Can anyone please help?

import Foundation

struct Curret {

    var currentTime: Int
    var temperature: Int
    var humudity: Double
    var precippossibility: Double
    var summary: String
    var icon: String


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

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

}
}

1 Answer

Hi Jason

just a few minor issues..

  var currentTime: Int
    var temperature: Int
    var humudity: Double   // you have it listed as a Double
    var precippossibility: Double  // you have a lowercase P here 
    var summary: String
    var icon: String
//Currently you have the following listed
        currentTime = currentWeather["time"] as Int
        temperature = currentWeather["temperature"] as Int
        humudity = currentWeather["humidity"] as Int // you have it listed as a int not a Double
        precipprobability = currentWeather["precipProbability"] as Double
        summary = currentWeather["summary"] as String
        icon = currentWeather["icon"] as String

// It should look like this.....
        currentTime = currentWeather["time"] as Int
        temperature = currentWeather["temperature"] as Int
        humudity = currentWeather["humidity"] as Double
        precippossibility = currentWeather["precipProbability"] as Double
        summary = currentWeather["summary"] as String
        icon = currentWeather["icon"] as String

Thank you Aaron, it appears to have solved the issue!.