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 trialRashii Henry
16,433 PointsiOS 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
Ernest Grzybowski
Treehouse Project ReviewerStone 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];
Stone Preston
42,016 Pointsive 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
16,433 PointsIve tried that as well.
it continues to prompt me with "make sure you create an NSArray named 'robotImages'."
Ernest Grzybowski
Treehouse Project ReviewerHey 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
16,433 Pointssorry about that, ill do that in the near future. i didn't see that button until you pointed it out.
J V
1,774 PointsI 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
16,433 Pointsi appreciate not giving me the answers. but using
NSArray *robotImages = (everything I had w/ or without the .png extension)
does not work.
J V
1,774 PointsPost your code here
J V
1,774 PointsJ V
1,774 PointsYup
Rashii Henry
16,433 PointsRashii Henry
16,433 Pointsin 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.
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerThat 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.
Rashii Henry
16,433 PointsRashii Henry
16,433 Pointsi apologize for the inconvenience. i forgot to insert a space after "initWithObjects:" that was the only difference in our codes. sorry about that ????
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerGreat! 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
16,433 PointsRashii Henry
16,433 PointsDont 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.
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerThis has been on the forum a few times.
https://teamtreehouse.com/forum/search?query=Set+the+animation+images+property+of+%27imageView%27+to+%27robotImages
Rashii Henry
16,433 PointsRashii Henry
16,433 Pointsis there anything wrong with my code?
self.booksArray = [NSArray arrayWithObjects:@"Hamlet",@"King Lear",@"Othello",@"Macbeth",nil];
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerPlease create a new forum post for each new question you have. Thanks!