您的位置:首页 > 移动开发 > Swift

Swift -- for 循环 Unary operator '++' cannot be applied to an operand of type '@lvalue Int'

2018-01-15 20:10 375 查看
for var i = 0; i < segmentArray!.count; i++ {

}
报错  Unary operator '++' cannot be applied to an operand of type '@lvalue Int’

替代方案

for i in 0..<self.segmentArray!.count {
print("--->", i)
}

// 递增
for i in 0 ..< self.segmentArray!.count {
}

// 递减
for i in (0 ..< self.segmentArray!.count).reversed() {
}

// NON-SEQUENTIAL INDEXING     Using where
for i in (0 ..< self.segmentArray!.count) where i % 2 == 0 {
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: