This question already has an answer here:
I just download a new Xcode (7.3) with swift 2.2.
It has a warning:
C-style for statement is deprecated and will be removed in a future version of Swift.
How can I fix this warning?
This question already has an answer here:
I just download a new Xcode (7.3) with swift 2.2.
It has a warning:
C-style for statement is deprecated and will be removed in a future version of Swift.
How can I fix this warning?
I got the same error with this code:
When you try to fix it with Xcode you get no luck... So you need to use the new swift style (for in loop):
For this kind "for" loop:
You can write:
Use this instead
Removing
for init; comparison; increment {}
and also remove++
and--
easily. and use Swift's pretty for-in loopSwift 2.2:
For decrement index
Or you can use
reverse()
likefor float type
(there is no need to define any types to index)
Swift 3.0:
From
Swift3.0
, Thestride(to:by:)
method on Strideable has been replaced with a free function,stride(from:to:by:)
For decrement index in
Swift 3.0
, you can usereversed()
Other then
for each
andstride()
, you can useWhile Loops
Repeat-While Loop:
check out Control flows in The Swift Programming Language Guide