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

Otto Wichmann
Otto Wichmann
4,827 Points

Add an image to the instance [...]

"Add an image to the instance of UITableViewCell named 'cell' with the previously created 'image' object."

Thats the task at hand. Im on the "UITableViewCell with an image" challenge from "Adapting Data for Display"

I've tried a lot of different code, I even search for some tutorials over at stackoverflow. But I honestly just don't know what to do. I was able to solve the first part of the challenge with this line of code:

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

And I understood why I had to write that line. But when it comes to adding the 'image' object to 'cell' I'm just lost.

Thank you in advance for any help!

Cheers

1 Answer

David Kaneshiro Jr.
David Kaneshiro Jr.
29,247 Points

Otto Wichmann,

This task is asking you to assign the image object to the imageView.image property of the UITableView cell object.

For example:

someCell.imageView.image = someImageObject;
Otto Wichmann
Otto Wichmann
4,827 Points

-___-

I can't believe it was that easy.

I wrote that line of code before but I was adding (@"") to image

cell.imageView.image = @"image";

Thank you David Kaneshiro Jr.