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

Rashii Henry
Rashii Henry
16,433 Points

iOS Image Based Animation Challenge help

Im having trouble with the Image Based Animation Code Challenge. It constantly tells me:

Recheck Work

Bummer! Make sure you create an NSArray named 'robotImages' with instances of UIImage objects.

and I've tried the following code:

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

they provided me with the following code and instructions :

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

4 Answers

Stone Preston you were dead on with the left side of the = but there is also the small problem of forgetting the .png on the right side of the equation.

With that said, the question states

"create an array of UIImage objects called 'robotImages'"

This tells you to start with an array (NSArray). of tells you what will be on the right side of the =. Lastly, called robotImages tells you the name of the NSArray object.

This leave you with:

NSArray *robotImages =

then you can add your right side (remember the .png this time)

Leaves you with:

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

Yup

Rashii Henry
Rashii Henry
16,433 Points

in the video, he stated that you dont have to type the png. thats why i didnt bother using it. but I've tried that code already and it does not work. i still receive the same message.

That code works 100%. Where are you putting the code? It says to specifically place it below the comment. Please paste your entire code if it still doesn't work. Sorry, yes you can leave out the .png. It's a personal preference of mine to include the file extension.

Once you pasted your entire code you can compare it with this. It passes the challenge.

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

/* Write your code below this line */
NSArray *robotImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"Robot1"], [UIImage imageNamed:@"Robot2"], [UIImage imageNamed:@"Robot3"], [UIImage imageNamed:@"Robot4"], nil];
Rashii Henry
Rashii Henry
16,433 Points

i apologize for the inconvenience. i forgot to insert a space after "initWithObjects:" that was the only difference in our codes. sorry about that ????

Great! That's glad to hear. Yes sometimes things as little as a space can have an effect on the outcome. Some of it is just the programming language and sometimes it's just how the challenge engine handles it. Either way, posting your full code is always a good idea. Glad you get to move onto the next part! Keep coding!

Rashii Henry
Rashii Henry
16,433 Points

Dont tell me the answer but can you summarize what this set of instructions is asking me to do?

this is the next step.

Set the animation images property of 'imageView' to 'robotImages'. Important: The code you write in each task should be added to the code written in the previous task.

i like how you thoroughly explained it earlier.

Rashii Henry
Rashii Henry
16,433 Points

is there anything wrong with my code?

self.booksArray = [NSArray arrayWithObjects:@"Hamlet",@"King Lear",@"Othello",@"Macbeth",nil];

Please create a new forum post for each new question you have. Thanks!

Stone Preston
Stone Preston
42,016 Points

ive not done this track before, but could it be that you initialized your array with the wrong name?

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

have you tried

NSArray *robotImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"Robot1"], [UIImage imageNamed: @"Robot2"], [UIImage imageNamed: @"Robot3"], [UIIMage imageNamed:@"Robot4"], nil];
Rashii Henry
Rashii Henry
16,433 Points

Ive tried that as well.

it continues to prompt me with "make sure you create an NSArray named 'robotImages'."

Hey Rashii Henry, please try to reply directly to @Stone Preston when responding directly to his answer. You can use the "Reply to this" link instead of using "Reply to this discussion". It makes it easier to see who you were responding to down the road. Thanks

Rashii Henry
Rashii Henry
16,433 Points

sorry about that, ill do that in the near future. i didn't see that button until you pointed it out.

I don't want to give you the answers. You should go back and Check the videos. I'm giving you a hint you have the wrong class and missing a variable. You need a new class and add variable. The answer is in the question.

Rashii Henry
Rashii Henry
16,433 Points

i appreciate not giving me the answers. but using

NSArray *robotImages = (everything I had w/ or without the .png extension)

does not work.

Post your code here