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 trialRick Wolchuk
2,063 PointsI need a little help with the UIImage view exercise
The question is asking to create an instance of UIImage:
Create an instance of UIImage called 'image' given the name of the image is 'placeholder.png'.
Here is the code that I entered and it is straight from the chapter tutorial: cell.imageView.image = [UIImage imageNamed:@“placeholder.png"];
The editor does not accept it and I'm stuck on how to proceed or what is wrong?
3 Answers
Nick Sint
4,208 PointsLets analyze this statement and compare it to what you did.
"Create an instance of UIImage called 'image' given the name of the image is 'placeholder.png'."
This statement is asking you to create an instance of UIImage THAT IS CALLED 'image'. Then, give that instance an image that is named 'placeholder.png'.
The code you wrote was: cell.imageView.image = [UIImage imageNamed:@“placeholder.png"]. This does not create an instance of UIImage called image. Instead, this line references an instance called cell. The second half of your code is defining cell's imageview's image property as a image called placeholder.png (therefore half of this line is correct).
I will give this hint. To create an instance of any class, the syntax is: Classname *instanceName;
If you are still stuck, let us know.
Patrick Cooney
12,216 PointsSo, typically a pointer represents an instance of an object. Your instance needs to be called "image". Look at the code you currently have and think about what you might need to replace to create an instance with the name "image".
Rick Wolchuk
2,063 PointsThat worked, thank you!