[Swift 1] Day 5 - Loops, Arrays, and Gestures


Day 5 Lecture

Today we’ll learn about loops (repetition), arrays (lists), and pan gestures (dragging or moving content).

Code Exercise: Design a single screen weather app UI.

  • Download some weather apps from the App Store for inspiration

Weekend App Challenge

The lesson will prepare you for the App Challenge over the weekend, where you’ll build an app to show a set of word magnets that you can move around (i.e. magnetic poetry)

Share any feedback about the lesson below.


These guys provide their wordlist for free.

Click on any kit and then “Download word list”. :smile:


I am getting this error when going through the arrays tutorial.
’(IntegerLiteralConvertible) -> $T2’ is not identical to ‘[String]’

And it later shows up as:
’(IntegerLiteralConvertible) -> $T4’ is not identical to ‘[String]’

when I reference “wordArray”.


Right i am now back from vacation and straight into Day 5 lessons. On 5.4 on Loops, i notice some strange things happening though. Can anyone help as to where i am going wrong or what has changed?

  1. the below doesn’t show on one line even when ‘ln’ is removed from the println

  1. second issue was i could not get the index,word example to work without error saying consecutive statements needed a : to work.

  2. My other examples were showing 110 times and the last one 121 times respectively…




  1. I’m not sure why it’s showing 110 times and 121 times for your loops, seems like a bug. What version of Xcode are you using?

  2. In Playgrounds when you see data displayed in-line, it’s not what is actually happening with the print keyword. It puts newlines in the in-line visualization that don’t actually exist.

  3. You have a typo in your code, wrong type of ending bracket. It should be curly

     var wordArray = ["I", "like", "to", "eat", "fruit", "my", "favorite"]
     for (index, word) in enumerate(wordArray) {
        println("index[\(index)] = \(word)")
  4. You need to look at the Console Output (Xcode Menu bar > View > Debug Area > Show Debug Area)

Xcode 6
Press the “Option/Alt + Command + Enter” shortcut to open up the Assistant Editor in Xcode 6, on the right you should see the “Console Output” with the printed text.

If you close the Console Output in the Assistant Editor mode, you can get it back by typing something in the Playgrounds code window and pressing return again (assuming you have print statements active).

Xcode 7
In Xcode 7 the Console Output is no longer displayed in the Assistant Editor, it’s below the code and can be shown with “Shift + Command + Y” for the Debug Console. There’s a little arrow icon in the bottom left corner of the playground.


Hi Paul,

  1. I am using Yosemite 10.10.4, Xcode version 6.4. My code results in playgrounds shows underneath.

  2. ok.

  3. Changed the bracket and checked the wording but still erroring.
    Screen shot attached.


When you have an issue I do recommend re-typing the code. You’ll find that you can fix an issue pretty fast that way.

You typed your variable incorrectly here, code is case sensitive. Index is not the same as index.


Noted with thanks Paul. I think all these little points i will be printing an laminating around my development room for those times when i get stuck. It’s now working fine.


I should probably make some kind of PDF printout of the common things to try.