JSON和swift的日摘要

时间:2016-05-15 08:56:13

标签: json swift

我很高兴获得当前和每小时的天气数据并基于以下标准:

的viewController:

让dailyWeather = weatherForecast.weekly [0]                     让hourlyWeather = weatherForecast.hourly [小时+4]

                let weeklyWeather = weatherForecast.weekly

                self.hourlySummaryLabel.text = hourlyWeather.hourlySummary
                self.tomorrowSummary.text = dailyWeather.summary

forecast.swift: struct Forecast {     var currentWeather:当前天气?     var每周:[DailyWeather] = []     var hourly:[HourlyWeather] = []

init(weatherDictionary: [String: AnyObject]){



    if let currentWeatherDictionary = weatherDictionary["currently"] as? [String: AnyObject] {
        currentWeather = CurrentWeather(weatherDictionary: currentWeatherDictionary)

    }

    if let weeklyWeatherArray = weatherDictionary["daily"]?["data"] as? [[String: AnyObject]] {

        for dailyWeather in weeklyWeatherArray {
            let daily = DailyWeather(dailyWeatherDictionary: dailyWeather)
            weekly.append(daily)

        }


    }

    if let hourlyWeatherArray = weatherDictionary["hourly"]?["data"] as? [[String:AnyObject]] {


        for hourlyWeather in hourlyWeatherArray {

            let hour = HourlyWeather(dailyWeatherDictionary: hourlyWeather)

            hourly.append(hour)

        }

    }

}

}

然而,我需要从以下json获得全天总结:

units = si;
}, "hourly": {
    data =     (
                {
                           {
            apparentTemperature = "33.61";
            cloudCover = 0;
            dewPoint = "12.77";
            humidity = "0.27";
            icon = "clear-day";
            ozone = "279.14";
            precipIntensity = 0;
            precipProbability = 0;
            pressure = "1004.85";
            summary = Clear;
            temperature = "34.66";
            time = 1463464800;
            windBearing = 4;
            windSpeed = "2.48";
        }
    );
    icon = wind;
    summary = "Breezy until this evening."; -----> Need This Summary

有什么办法吗?

0 个答案:

没有答案