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 Object-Oriented Objective-C Memory, Arrays and Loops, Oh My! NSArrays and For In Loops

Not sure how to create the for in loop

I've watched the video twice and I still don't understand how I'm supposed to create it.

nsarray.mm
NSArray *drinks = @[@"juice", @"water", @"coffee"];

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Challenge Task 2 of 2

Create a "for in" loop to iterate over drinks and print out each drink name using NSLog.

the use of for...in loop was covered in this lecture at around 03:40 time stamp.

The for...in loop you're going to write for this challenge is quite similar to what the instructor presented during the lecture. The difference is that now you have an Array of NSString instead of NSNumber.

NSArray *drinks = @[@"juice", @"water", @"coffee"];

for (NSString *arg in drinks) {
  NSLog(@"%@", arg);
}

Hope it helps.