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 Build a Simple iPhone App (iOS7) Designing your App Programming a Background Image

Jake Adam
Jake Adam
9,226 Points

iOS Background image code challenge help

I dont understand what is wrong with my code here:

UIImage *background = [UIImage imageNamed: @"background"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:@"background"];

The question is asking to fix the previous code and set imageView to an object Image

1 Answer

aldoolivares
aldoolivares
14,478 Points

It simply means that you need to use the UIImage that you just created,like this:

UIImage *background = [UIImage imageNamed: @"background"];

UIImageView *imageView = [[UIImageView alloc] initWithImage:background]; 

In your second like you were trying to pass a string (@"background"), but it needed your UIImage *background variable.

Cheers :D

Jake Adam
Jake Adam
9,226 Points

Thank you so much!