Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 !