0

I have search a bit online but being new to Swift, I couldn't find anything that helped me convert a for loop to the upcoming Swift version.

I have this

for var i: CGFloat = start; i <= stop; i += step {

and trying to convert to the new format but unsure how.

Can someone please help before my code stops working?

Thanks :)

puks1978
  • 3,667
  • 11
  • 44
  • 103

2 Answers2

0
  for i in number.stride(through: toSecondNumber, by: withStep) 

where i - name for you variable

number - start value of i

secondNumber - lastValue of range

withStep - step of iteration

you can you through to include last value or to to exclude last value

wm.p1us
  • 2,019
  • 2
  • 27
  • 38
0

You should use 'stride' keyword.

More info about your solution.

itsji10dra
  • 4,603
  • 3
  • 39
  • 59