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

Errors

I have wrote a program and Xcode is saying two errors:

import UIKit

for var i = 0; i< todo.count; i++; { println(todo[i]) }

The errors are :

Line 1: Statement cannot begin with a closure expression Line 2: Use of un resolved identifier "i"

I don't get the second line since i had told the computer i = 0

3 Answers

for var i = 0; i < todo.count; i++ { println(todo[i]) }

You should check this LINK, where you'll find all explained for Control Flow in swift.

for (int i = 0; i< todo.count; i++) { println(todo[i]) }

Try this then.

Got a bit mixed up before. I'm just doing the JavaScript course and var is used for JS but in C, C++ & Objective C you have to declare a variable with the variable type.

The first line worked, so thank you. In your code you declare int i = 0 In the second line the error says Use of unresolved identifier "i". It is showing the same error. Could you help please. This is in the language Swift by the way.

for (var i = 0; i< todo.count; i++) { println(todo[i]) }

Thats your answer.

To clarify follow this LINK, it's a external link to a site explaining the Objective-C FOR loop.

Hope this helped to get you going.

Sorry but this didn't work I appreciate you trying to help me though