我正在使用的天气应用程序。我获得了预测数据,预测的每一天都有NSArray
。该数组如下所示:
(
{
apparentTemperatureMax = "73.44";
apparentTemperatureMaxTime = 1467500400;
apparentTemperatureMin = "47.12";
apparentTemperatureMinTime = 1467457200;
cloudCover = "0.75";
dewPoint = "43.53";
humidity = "0.58";
icon = rain;
moonPhase = "0.9399999999999999";
ozone = "276.53";
precipIntensity = "0.0036";
precipIntensityMax = "0.0092";
precipIntensityMaxTime = 1467504000;
precipProbability = "0.44";
precipType = rain;
pressure = "1015.28";
summary = "Light rain starting in the afternoon.";
sunriseTime = 1467460332;
sunsetTime = 1467513207;
temperatureMax = "73.44";
temperatureMaxTime = 1467500400;
temperatureMin = "47.12";
temperatureMinTime = 1467457200;
time = 1467439200;
windBearing = 281;
windSpeed = "0.54";
}
)
我把所有的日子都合并成一个巨人NSMutableArray
。我想要做的是将NSMutableArray
作为UITableView
的来源,但只输入一些天气数据,如temperatureMin,temperatureMax,precipProbability等。对于我来说,最好的方法是采用包含多个数组的NSMutableArray
,并且只显示每个数组中的一些信息?
更新:
这是完整的NSMutableArray:
(
(
{
apparentTemperatureMax = "73.44";
apparentTemperatureMaxTime = 1467500400;
apparentTemperatureMin = "47.12";
apparentTemperatureMinTime = 1467457200;
cloudCover = "0.75";
dewPoint = "43.53";
humidity = "0.58";
icon = rain;
moonPhase = "0.9399999999999999";
ozone = "276.53";
precipIntensity = "0.0036";
precipIntensityMax = "0.0092";
precipIntensityMaxTime = 1467504000;
precipProbability = "0.44";
precipType = rain;
pressure = "1015.28";
summary = "Light rain starting in the afternoon.";
sunriseTime = 1467460332;
sunsetTime = 1467513207;
temperatureMax = "73.44";
temperatureMaxTime = 1467500400;
temperatureMin = "47.12";
temperatureMinTime = 1467457200;
time = 1467439200;
windBearing = 281;
windSpeed = "0.54";
}
),
(
{
apparentTemperatureMax = "69.59";
apparentTemperatureMaxTime = 1467576000;
apparentTemperatureMin = 56;
apparentTemperatureMinTime = 1467540000;
cloudCover = "0.41";
cloudCoverError = "0.35";
dewPoint = "45.21";
dewPointError = "10.53";
humidity = "0.55";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.97";
precipType = rain;
pressure = "1016.93";
pressureError = "1.78";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1467546762;
sunsetTime = 1467599598;
temperatureMax = "69.59";
temperatureMaxError = "9.68";
temperatureMaxTime = 1467576000;
temperatureMin = 56;
temperatureMinTime = 1467540000;
time = 1467525600;
visibility = 10;
visibilityError = "1.98";
windBearing = 217;
windBearingError = "38.17";
windSpeed = "6.24";
windSpeedError = "4.9";
}
),
(
{
apparentTemperatureMax = "69.69";
apparentTemperatureMaxTime = 1467662400;
apparentTemperatureMin = "55.94";
apparentTemperatureMinTime = 1467622800;
cloudCover = "0.39";
cloudCoverError = "0.35";
dewPoint = "45.61";
dewPointError = "9.890000000000001";
humidity = "0.55";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.02";
precipType = rain;
pressure = "1017.46";
pressureError = "1.74";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1467633192;
sunsetTime = 1467685988;
temperatureMax = "69.69";
temperatureMaxError = "9.69";
temperatureMaxTime = 1467662400;
temperatureMin = "55.94";
temperatureMinError = "9.48";
temperatureMinTime = 1467622800;
time = 1467612000;
visibility = 10;
visibilityError = 2;
windBearing = 216;
windBearingError = "35.68";
windSpeed = "6.72";
windSpeedError = "4.83";
}
),
(
{
apparentTemperatureMax = "69.78";
apparentTemperatureMaxTime = 1467748800;
apparentTemperatureMin = "56.03";
apparentTemperatureMinTime = 1467709200;
cloudCover = "0.39";
cloudCoverError = "0.35";
dewPoint = "45.91";
dewPointError = "9.67";
humidity = "0.5600000000000001";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.05";
precipType = rain;
pressure = "1017.36";
pressureError = "1.7";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1467719624;
sunsetTime = 1467772376;
temperatureMax = "69.78";
temperatureMaxError = "9.65";
temperatureMaxTime = 1467748800;
temperatureMin = "56.03";
temperatureMinError = "9.470000000000001";
temperatureMinTime = 1467709200;
time = 1467698400;
visibility = 10;
visibilityError = 2;
windBearing = 215;
windBearingError = "35.59";
windSpeed = "6.7";
windSpeedError = "4.8";
}
),
(
{
apparentTemperatureMax = "69.84999999999999";
apparentTemperatureMaxTime = 1467835200;
apparentTemperatureMin = "56.11";
apparentTemperatureMinTime = 1467795600;
cloudCover = "0.4";
cloudCoverError = "0.35";
dewPoint = "46.2";
dewPointError = "9.470000000000001";
humidity = "0.5600000000000001";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.08";
precipType = rain;
pressure = "1017.26";
pressureError = "1.67";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1467806058;
sunsetTime = 1467858761;
temperatureMax = "69.84999999999999";
temperatureMaxError = "9.57";
temperatureMaxTime = 1467835200;
temperatureMin = "56.11";
temperatureMinError = "9.41";
temperatureMinTime = 1467795600;
time = 1467784800;
visibility = 10;
visibilityError = 2;
windBearing = 214;
windBearingError = "35.54";
windSpeed = "6.67";
windSpeedError = "4.77";
}
),
(
{
apparentTemperatureMax = "69.91";
apparentTemperatureMaxTime = 1467921600;
apparentTemperatureMin = "56.17";
apparentTemperatureMinTime = 1467882000;
cloudCover = "0.41";
cloudCoverError = "0.35";
dewPoint = "46.47";
dewPointError = "9.32";
humidity = "0.57";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.12";
precipType = rain;
pressure = "1017.16";
pressureError = "1.63";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1467892492;
sunsetTime = 1467945146;
temperatureMax = "69.91";
temperatureMaxError = "9.449999999999999";
temperatureMaxTime = 1467921600;
temperatureMin = "56.17";
temperatureMinError = "9.300000000000001";
temperatureMinTime = 1467882000;
time = 1467871200;
visibility = 10;
visibilityError = 2;
windBearing = 213;
windBearingError = "35.55";
windSpeed = "6.63";
windSpeedError = "4.74";
}
),
(
{
apparentTemperatureMax = "69.95999999999999";
apparentTemperatureMaxTime = 1468008000;
apparentTemperatureMin = "56.23";
apparentTemperatureMinTime = 1467968400;
cloudCover = "0.41";
cloudCoverError = "0.35";
dewPoint = "46.71";
dewPointError = "9.23";
humidity = "0.57";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.15";
precipType = rain;
pressure = "1017.08";
pressureError = "1.6";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1467978927;
sunsetTime = 1468031528;
temperatureMax = "69.95999999999999";
temperatureMaxError = "9.31";
temperatureMaxTime = 1468008000;
temperatureMin = "56.23";
temperatureMinError = "9.17";
temperatureMinTime = 1467968400;
time = 1467957600;
visibility = 10;
visibilityError = "2.01";
windBearing = 212;
windBearingError = "35.64";
windSpeed = "6.57";
windSpeedError = "4.71";
}
),
(
{
apparentTemperatureMax = "69.98999999999999";
apparentTemperatureMaxTime = 1468094400;
apparentTemperatureMin = "56.26";
apparentTemperatureMinTime = 1468054800;
cloudCover = "0.42";
cloudCoverError = "0.35";
dewPoint = "46.94";
dewPointError = "9.18";
humidity = "0.57";
humidityError = "0.19";
icon = "partly-cloudy-day";
moonPhase = "0.18";
precipType = rain;
pressure = "1017.01";
pressureError = "1.58";
summary = "Partly cloudy throughout the day.";
sunriseTime = 1468065364;
sunsetTime = 1468117908;
temperatureMax = "69.98999999999999";
temperatureMaxError = "9.17";
temperatureMaxTime = 1468094400;
temperatureMin = "56.26";
temperatureMinError = "9.029999999999999";
temperatureMinTime = 1468054800;
time = 1468044000;
visibility = 10;
visibilityError = "2.01";
windBearing = 211;
windBearingError = "35.84";
windSpeed = "6.48";
windSpeedError = "4.68";
}
)
)
答案 0 :(得分:0)
在表的源中有两种方法可以使用数组。
1-你可以从数组中获取值 - 前 -
NSString * temperatureMax_Str = [NSString stringWithFormat:@"%@",[[Array objectAtIndex:indexPath.row] valueForKey:@"temperatureMax"]];
2-创建一个NSDictionary并从数组中添加值 -
NSDictionary *Dic = [Array objectAtIndex:indexPath.row];
NSString * temperatureMax_Str = [Dic valueForKey:@"temperatureMax"];
还有其他一些方法,你也可以尝试创建可变字典等。
答案 1 :(得分:0)
使用此单行代码temp
,
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> </head> <body> <p>HELLO WORLD</p> </body> </html>
希望它有用
答案 2 :(得分:0)
您应该创建一个模型对象,例如WeatherObject
类并将您的响应解析为此类对象的数组。丢弃您在解析过程中丢弃的任何字段。您可以将NSMutableArray
WeatherObject
设置为表格视图的数据源。这将是更加面向对象和人类可读的代码。