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
kirhim lee
1,517 PointsCode Challenge
I didn't fully understand this chapter but I want to move on but can't complete this challenge can anyone help?
Challenge: Create a "for in" loop to iterate over drinks and print out each drink name using NSLog.
NSArray *drinks = @[@"juice", @"water", @"coffee"];
for (NSArray * name in drinks)
NSLog (@"%", name);
2 Answers
Miles Ranisavljevic
3,591 PointsYou are close, but just have the type wrong. When you declare a for-in loop, you need to declare the type of the individual members of the array - not the type of the array itself. So, in this case, you need to change
for (NSArray * name in drinks)
to
for (NSString* name in drinks)
Additionally, you need to make sure you put the curly braces in there on the part that will be executed for each iteration.
for (NSString* name in drinks) {
NSLog(@"%@", name);
}
kirhim lee
1,517 PointsThank you too much!
Miles Ranisavljevic
3,591 PointsYou're welcome!