Watching some graphics
Knowing that a loop iterates eight times instead of 54 is fine. It gives you a good idea about the best algorithm to choose, but there are times when we need to visualize the variable's values during the loop iterations; for cases like this, Apple has created the timeline.
Getting ready
You can open your Xcode and click on Get started with playground, or if you already have your Xcode opened, you can go to File | New | Playground.
Name your project Chapter 6 Timeline
and save it at your workspace folder.
How to do it...
In order to enable the app to watch some graphics, follow these steps:
First, let's type a code where we print some output. In this case, we will print a triangle with stars.
for i in 1...5 { for j in 1...i { print("*") } println() }
Once you've typed this code, you wouldn't appreciate the triangle yet. Go to the icon that looks like two overlapped circles and click on it. The icon is shown here:
Behold, the Xcode split in two parts. The...