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

ios code challenge Help!: Add and image to the instance of UITableViewCell named 'cell' with the previously created 'image' object.

MY code: UITableViewCell cell = [[UITableViewCell alloc] init]; / Write your code below this line */ UIImage *image= [UIImage imageNamed:@"placeholder.png"]; self= [self addImage:@"image"];

12 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Don't want to give away the answer so let me phrase as a fill in the blank:

UITableViewCell cell = [[UITableViewCell alloc] init]; 
// Write your code below this line 
UIImage *image= [UIImage imageNamed:@"placeholder.png"]; 
// You need to use set the image to the imageView property of cell
cell.imageView._____ = ________;
Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

You are close except that the image is already defined in the previous line so need not define it again.

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

You have to set the "image" object to the "cell" object as in the video at the 4:00 minute mark.

After hours of working on this problem, I finally solved it! It makes me want to learn more. I appreciate you not giving me the answer.

Thanks again

Sorry I don't understand.

Yes thank you. I don't want answers I just want tips. I'm going to watch the video again. Amit I enjoy your style of teaching. I hope to see more new videos from you!

cell.imageView.image= [UIImage imageNamed:@"placeholder.png"];

I feel like like I need to understand this better because I'm really struggling. I'm still getting it wrong.

Im still not sure how to do this question. Can someone explain please.

thanks

Hey Ryan,

I think there is some bug on the code challenge, cause when you hit this to the first question it goes right :

UIImage *image = [UIImage imageNamed:@"placeholder"];

But when you hit this to the second question it says its incorrect:

cell.imageView.image =image;

So you have to put exactly this code to solve the problem:

UIImage *image = [UIImage imageNamed:@"placeholder.png"]; cell.imageView.image =image;

Don't know why but the lack of ".png" from the first answer makes the second answer incorrect.

Hope it could help you!

Thank you so much. That is so frustrating, i had that code hours ago but to have to put it on the same line ahhahhhhhhhhhhhhhh that was nuts!!!

I thought that .png wasn't needed for file names... :P I got kind of caught up on all that

Had the same issue. @"placeholder" works for challenge 1, but you have to change this to @"placeholder.png" in order to pass challenge 2 :/

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Sorry about that it should be fixed now.