首先参考下面的图形显示:
我有一个包含9个元素的NSArray。 这9个元素中的每一个都包含另外5个元素。
我想做的是将每个地方的 var strYears = form.years.value;
var strMonths = form.months.value;
var strDays = form.days.value;
var Y = parseInt(strYears);
var m = parseInt(strMonths);
var q = parseInt(strDays);
var h = "";
var output = "";
if (isNaN(Y))
throw ("Incorrect input. Years is not a number.");
if (Y < 0 || Y > 9999)
throw "Incorrect input. Years is out of expected range (0-9999).";
if (isNaN(m))
throw "Incorrect input. Months is not a number.";
if (m < 1 || m > 12)
throw "Incorrect input. Months is out of expected range (1-12).";
if (isNaN(q))
throw "Incorrect input. Days is not a number.";
if ((q < 1 || q > 31) && (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12))
throw "Incorrect input. Days is out of expected range (1-31).";
if ((q < 1 || q > 30) && (m == 4 || m == 6 || m == 9 || m == 11))
throw "Incorrect input. Days is out of expected range (1-30).";
if ((q < 1 || q > 28) && (m == 2) && ( q % 4 === 0 ) && (!( q % 100 )))
throw "Incorrect input. Days is out of expected range (1-28).";
if (m == 1 || m == 2) {
m = m + 12;
Y = Y - 1;
}
h = (q + Math.floor(13 * (m + 1) / 5) + Y + Math.floor(Y / 4)
- Math.floor(Y / 100) + Math.floor(Y / 400)) % 7;
{
if (h == 0)
h = "Saturday";
if (h == 1)
h = "Sunday";
if (h == 2)
h = "Monday";
if (h == 3)
h = "Tuesday";
if (h == 4)
h = "Wednesday";
if (h == 5)
h = "Thursday";
if (h == 6)
h = "Friday";
var output = h;
document.getElementById("output").innerHTML = output;
}
}
catch(error){
document.getElementById("output").innerHTML = "Error: " + error;
}
}`
带到另一个地方,只包含这些日期。
如何最好地实现?
答案 0 :(得分:2)
NSMutableArray * results = [@[] mutableCopy];
for (NSArray *details in self.fuelDetailsForSelectedBike){
[result addObject:details[1]];
}
答案 1 :(得分:0)
这看似相当基本,循环遍历主数组,并为每个对象(即数组)取得它的第二个元素并将其添加到结果中。