iOS Swift Collections and Control Flow Control Flow With Loops While and Repeat While

Matthew Lurie
Matthew Lurie
3,512 Points

Why does my while loop go 17452 times?

The video says it should go for 20 or 21 times.

andren
andren
28,431 Points

It's likely an error in the condition of the loop, which is what determines when the loop ends. But I have to see your code to see precisely what the issue is. And the code is not currently attached to your post.

If you edit your post and paste in the code you are running then I can point out exactly what is happening.

Matthew Lurie
Matthew Lurie
3,512 Points

Really frustrating that sometimes there is a checkbox to attach my code, sometimes there is not. No idea why.

Separately, a few moments later, Xcode crashed. I re-opened it, inputted same code and now it gives expected result. That was a great use of 20 minutes ?

Emin Grbo
Emin Grbo
13,092 Points

No need to use the checkbox. You can just copy the code and enter it between these tags:

```swift

```

So you add 3 "ticks" like this one ` and name of the language and then close it with same 3 ticks but without the language name.

You also have a link for the "Markdown Cheatsheet" when writing a comment, just above the "Cancel" button ;)

Matthew Lurie
Matthew Lurie
3,512 Points

thanks Emin - will keep that in mind in future posts!:)