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.

Gregg Mojica
11,506 PointsUiImage Code Challenge
Hi Guys, Stuck on this question:
Question Next we need a UIImageView to display the pizza slice UIImage. Create a UIImageView variable and set its 'image' property to the UIImage variable you just created.
My Code [UIImage imageNamed: @"pizza_slice"]; UIImageView *myView = [[UIImageView alloc] init];
Not sure where to go from here...
Thanks!
4 Answers

Stephen Whitfield
16,771 Pointsor you could stick it all on one line. like this:
UIImageView *myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pizza_slice"]];

Gregg Mojica
11,506 PointsFigured it out! UIImage *images; [UIImage imageNamed: @"pizza_slice"]; UIImageView *myView = [[UIImageView alloc] init]; myView.image = images;

R Brewster
15,328 PointsThis seems to work
[UIImage imageNamed:@"pizza_slice"]; UIImageView *pizzaImage = [[UIImageView alloc] init]; pizzaImage.image = [UIImage imageNamed:@"pizza_slice"];

Stephen Whitfield
16,771 PointsIt works, but you're breaking the DRY (Don't Repeat Yourself) principle. The UIImage declaration in that first line is not needed, as you have already assigned that image to your UIImageView in the last line. Take that out and you'll be fine.

R Brewster
15,328 PointsGood point. Thanks Stephen.