Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Control Flow While and Do-While Loop

Harold Bellemare
Harold Bellemare
1,466 Points

Xcode changes?

For most of the course, I've been using the Treehouse iPad app, and have had no problems. Today, I fired up Xcode on my Mac to do this lesson, and I ran into a couple of discrepancies:

  1. Xcode told me to change println() to print() — no big deal, except, is it still possible to use the original functionality of print(), without a line break, if desired?

  2. Show Assistant Editor doesn't show the console output. Instead, it's a mostly-empty pane. There is, however, an upward-facing arrow in the lower left-hand corner of the window with the tooltip "Show the Debug area"; this is the best I could come up with. Is this what I should be doing?

Note: I'm using the beta version, if that matters. I figure I might as well get used to the way things might be in the next version.

I didn't realize this, at first, but there's a third issue (being that do-while loops are now called repeat-while loops). All told, my code had to be changed to this, in order to be parsed correctly:

import UIKit


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

var index = 0

while index < todo.count {
    print(todo[index])
    index++
}

index = 0

repeat {
    print(todo[index])
    index++
} while index < todo.count

1 Answer

Jhoan Arango
Jhoan Arango
14,561 Points

Hello Harold :

Yes Harold these are changes to the swift language. With the upcoming version of Swift 2.0 there will be some upgrades and changes to the language. If you just upgrade to the beta version, you’ll see that Xcode will prompt you to migrate your existing codes to Swift 2.0.