如何设置变量从 0 开始,并在嵌套的 for 循环中通过每个循环获得一个级别 Swift 2

How to set a variable to start at 0 and gain a level through each loop in a nested for loop Swift 2

所以这是 swift 2 中嵌套 for 循环的一个示例。在这个循环的正上方和正下方有一个 for 循环,一个接一个地工作。每次调用 for 循环时,我都想爬一个级别。通常,如果这是一个 for 循环,它会自动发生,但由于它是一个嵌套的 for 循环,我需要它 运行 一次,然后跳转到下一个 for 循环。

问题在于 var u 为 0,它始终设置为 0,并且始终从此处开始。有没有办法让它采用 post place[u] = place[++]?

的形式
placeLoop: for aPlace in place {
                print("\(aPlace)")
                print(" ")
                var u : Int = 0
                if aPlace == place[u] {
                    place[u] = place[++u]
                    //This is the manual way to achieve what I want but I have 105 records I want to iterate through, there has to be a better way to do this.
                    //place[u] = var place[u]
                    //place[1] = place[2]
                    //place[2] = place[3]
                    //if aPlace is equal to place0 then 0 = 1, next loop 1 = 2, next loop 2 =3
                    //you can't ++ a "String which place[with an index] is.

我一直在通读这个 documentation 并查看了许多不同的 Whosebug 问题,但到目前为止没有任何帮助......我正在考虑一个 switch 语句,但不确定它是否会有任何不同的工作方式。

编辑:

for a in coor {
    for aPlace in place {
         for aPass in pass {


}}}

数据为 geojson 格式: 颜色:双(2343.90) 地方:字符串(“asdfsa”) pass: 字符串 (" asdfkkrr ")

再加 3 条记录

我需要它 return 以便按此顺序在我的代码中进一步输入: coor1、place1 和 pass1,然后是 coor2、place2 和 pass2,等等。

在第一个 for 循环之外定义 u 变量,在外部循环结束时定义 u += 1

检查这个

var u : Int = 0
placeLoop: for aPlace in place {
             print("\(aPlace)")
             print(" ")

             if aPlace == place[u] {
             place[u] = place[++u]
             //This is the manual way to achieve what I want but I have 105 records I want to iterate through, there has to be a better way to do this.
             //place[u] = var place[u]
             //place[1] = place[2]
             //place[2] = place[3]
             //if aPlace is equal to place0 then 0 = 1, next loop 1 = 2, next loop 2 =3
             //you can't ++ a "String which place[with an index] is.
             u += 1

希望对您有所帮助,此致