我有 2 个动态创建的数组。我在网上阅读了一些例子,我无法完全理解。我看到的是,数组似乎是 1 维而不是 2。
下面的代码将一些对象分配给数组“combineObjectIssues”,然后将其添加到“combineAll”中以获得二维数组。我希望“currentObject.date”为索引 0,而“issuesDiscovered”数组为索引 1。
for (currentObject in currentObjects) {
[combineObjectIssues addObject:currentObject.date]; //2D Array Row
for (Issue *checkIssue in currentObject.issuesDiscovered) {
if (checkIssue) {
[issuesDiscovered addObject:checkIssue];
}
}
[tempIssues addObject:[issuesDiscovered copy]]; // to combine all array of issues
[combineOjectIssues addObjectsFromArray:[issuesDiscovered copy]]; //2D Array column
[combineAll addObject:[combineObjectIssues copy]];
[issuesDiscovered removeAllObjects]; //remove all objects;
[combineObjectIssues removeAllObjects]; //remove all objects
}
}
下面是 combineAll 数组的输出。
(
(
"2013-07-19 09:00:00",
"<Issue: 0x8c171f0>",
"<Issue: 0x8c16e50>",
"<Issue: 0x8c16d30>",
"<Issue: 0x8c16a10>",
"<Issue: 0x8c16090>",
"<Issue: 0x8c15bb0>",
"<Issue: 0x8c156d0>"
),
(
"2013-07-13 14:30:00"
),
(
"2013-06-08 14:30:00",
"<Issue: 0x8c10340>",
"<Issue: 0x8c0fad0>",
"<Issue: 0x8c0f590>",
"<Issue: 0x8c0f0c0>"
),
(
"2013-05-04 11:30:00"
)
)
从输出中可以看出,它是一个我不想要的一维数组。我想要类似的东西,对于 [0][0],它包含日期,而对于 [0][1],它包含一系列问题。
我知道我的代码可能不正确。因此,请帮助我。感谢您的协助。