Replacement for C-style loop in Swift 2.2

后端 未结 4 551
故里飘歌
故里飘歌 2020-11-27 08:01

Swift 2.2 deprecated the C-style loop. However in some cases, the new range operator just doesn\'t work the same.

for var i = 0; i < -1; ++i { ... }
         


        
4条回答
  •  生来不讨喜
    2020-11-27 08:41

    For Swift 3 and need to change the "index"

    for var index in stride(from: 0, to: 10, by: 1){}
    

提交回复
热议问题