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

Quiz in "iOS Development" series.

Assume you have images named 'Robot1.png','Robot2.png','Robot3.png','Robot4.png', create an array of UIImage objects called 'robotImages'.

My answer : NSArray * robotImages = [[NSArray:alloc] initWithObjects:[UIImage imageNamed:@"Robot1"],[UIImage imageNamed:@"Robot2"],[UIImage imageNamed:@"Robot3"], [UIImage imageNamed:@"Robot4"],nil];

Sorry, I am a newbie. Can someone explain, wahtI am doing wrong.

Thanks, Nandu

4 Answers

Nathan F.
Nathan F.
30,773 Points

You're missing an important piece of information in your array.

Suppose you also had in your resources these items: 'Robot1.jpg', 'Robot2.jpg','Robot3.jpg','Robot4.jpg'

How would you tell these two sets of items apart? How would you tell the computer which set of resources you wanted?

Thanks Nathan for your reply! Appreciate it !

In the videos they seemed to have skipped the ".png" part of it. So I assumed the same :(

Anyway, I tried adding the .png suffixes as follows. But still I can't get past the quiz :-( :-(

New Answer (with ".png" added): NSArray * robotImages = [[NSArray:alloc] initWithObjects:[UIImage imageNamed:@"Robot1.png"],[UIImage imageNamed:@"Robot2.png"],[UIImage imageNamed:@"Robot3.png"], [UIImage imageNamed:@"Robot4.png"],nil];

It still tells me it i wrong :(

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Your answer is almost right but you have a misplaced colon [NSArray:alloc] it should be [NSArray alloc].

Hi Amit, Thanks ! Thats so silly of me ! Thanks for the videos. I enjoy learning from them. Would be nice if there is a more in depth version of Objective-C tutorials. Thanks !