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

Image Based Animation (Code Challenge)

Having trouble on this one.

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

UIImage *image = [UIImage imageNamed:@"robot.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

/* Write your code below this line */

self.imageView.robotImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"Robot1.png"], [UIImage imageNamed:@"Robot2.png"], [UIImage imageNamed:@"Robot3.png"], [UIImage imageNamed:@"Robot4.png"], nil];

8 Answers

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Hey Jesse,

I'm not sure what's going on here, but I'll ping Amit so that he can get back to you.

Do the challenge as if there was no property set... so your code would look like:

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

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

I tried your code above and couldn't get it to work.

Afternoon Folks,

I completed the first task to create the array of images however I'm stumped on the second task:

"Set the 'robotImages' to the animation images property of 'imageView'"

Can anyone help explain this task please?

Never mind I got it

This answer is for Ralph Ritter III

The second code challenge can be completed with:

The answer is pretty self explanatory since it is a short question/answer

imageView.animationImages = robotImages;

for anyone that comes across this down the road.

sorry, should have posted this with my response, thanks Ernest!

I got stuck on this too as it was taught how to write an array that way with the predictionArray but for me that was a few days ago. It would be nice to have a bit more help early on as to why the challenges are done the way they are.

I get a bit frustrated with myself when I'm doing a challenge and its not working even though I did it just the way it was taught in the video I just watched, not calling to memory right away what was taught a couple videos previously.

This still does not explain it to me.