Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.

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!:)

1 Answer

andren
andren
28,558 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.