【发布时间】:2017-10-16 10:44:24
【问题描述】:
我正在尝试遍历整个数组直到最后寻找特定元素,即使找到它,直到它在第一次找到它之前一直在工作。 就像我有一个名为 a = [a,b,c,d]//(prodname) 的数组和它的 id 的其他数组 i = [0,1,1,1] // prodAppid
现在我想要创建一个数组,其中包含数组 a 的项,其 id 为 1,它应该是 final = [b,c,d] // TargetProducts1。
到目前为止,我得到了 final = [b,b,b],它不会更进一步。这是我的代码
for items in prodAppid {
if var i = prodAppid.index(of: v_targetapplication) {
print("Product id is at index \(i)")
print("product Name = \(prodname[i])")
// product1Text.text = prodname[i]
// TargetProducts1.append([prodname[i]])
TargetProducts1.append(prodname[i])
print("Target products for this application = \(TargetProducts1)")
} else {
print("Product Doesn't exsit for this Application")
product1Text.text = "No Product available for this Application!"
}
}
【问题讨论】:
-
什么是
v_targetapplication?它的价值是什么?
标签: ios arrays swift append traversal