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 Basics (retired) Control Flow While and Do-While Loop

how to stop infinite loop

when going through this lesson I got in an infinite loop, I can't even get back into xcode now. need help please.

Sidney Eubanks
Sidney Eubanks
3,864 Points

I think command z can get out out of it.

1 Answer

you have to add


to your loop to increment your index or it can crash xcode. I would just make a new playground WITH that line in it and delete the old one.

var todo : [String] = [ "Return calls",
                        "Write post",
                        "Cook dinner",
                        "Pickup Laundry",
                        "Buy hyacinth bulbs" ]

var index = 0

while index < todo.count {