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\ If statments\ for

I get conufused a little bit. Please look into code written below, I do not quetie understand what index, number or card mean. And how do I know which one and when to use??

and the next question is... if I learn swift not objective-C (I find it complex for begginers in programming such as me) will I find a job as an IOS Developer who writes on Swift? We know that Objective-C was around quite for a long time, and IOS companies will not run and rewrite their apps to Swift. Thanks in Advance

For card in cards { }

for index in month { }

for number in numbers { }

1 Answer

Jayden Spring
Jayden Spring
8,625 Points

Hi Kamran,

ObjC and Swift are two different languages, although they both are based on Smalltalk using dynamic messaging they have their differences. Therefore being able to work proficiently in Swift would not mean you would necessarily understand ObjC. However if you had a profound understanding of ObjC then Swift would be easier to adopt. As a beginner I would suggest learning Swift as this is the new up-and-coming language, it is much more elegant and it can be more efficient to use in certain scenarios.

With regards to your first question I would recommend having a look at the Apple Documentation for control flows. As an example, lets say you have an array called 'people' and you want to iterate through and get everyones name:

  let people : [String] = ["Mark", "David", "John", "Sarah"]
  for name in people {
    println("This Persons Name Is \(name)")
  }

The syntax of the for loop here is for [index] in [collection] - therefore when we go through the array of people we are saying each time we advance to a new index, name is a reference to the value of that index.

Hope this helps.