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!
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

Steve B
6,257 Pointsprogramming a background image code challenge
Building a simple iPhone app 5:4
http://teamtreehouse.com/library/programming-a-background-image-2
Im having trouble passing this challenge, I've looked at this a thousand times and I cant see whats wrong - Im sure its stupidly obvious!
My code
// The following code is excerpted from
// the viewDidLoad method of THViewController.m
// Fix the code below
// Hint: First create an instance of UIImage
UIImage *background = [UIImage imageNamed:@"background"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: background];"
4 Answers

Stone Preston
42,016 Pointscurrently you have a double quote at the end of your last line. try removing it:
What you currently have:
UIImage *background = [UIImage imageNamed:@"background"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: background];"
remove the quote:
UIImage *background = [UIImage imageNamed:@"background"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: background];
also, the imageView may be a property of your viewController (it most likely is), so you might need to access it using self and access the image property of the imageView like so: (also note that you wouldnt allocate/init it if it was a property):
UIImage *background = [UIImage imageNamed:@"background"];
self.imageView.image = background;

Andrew Pope
11,915 PointsThe code is right, however you just have a " at the end of the last line which is creating the error! Delete it and it should be fine.

Ezequiel Amaya
3,094 Pointswhat about the " at the end of the line? ...
UIImageView *imageView = [[UIImageView alloc] initWithImage: background];"
also for imageNamed: call ...
"On iOS 4 and later, if the file is in PNG format, it is not necessary to specify the .PNG filename extension"
is "background" a png file?

Steve B
6,257 PointsYes, it was quotation mark!
Thanks for your help peeps :-)
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you post a link to the challenge and what task you are on