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 Build a Diary App Using Core Data Custom Detail View Controller Entry Detail View Controller

Mood buttons not changing the image

Really quick question ... where is the code that selects the appropriate image for each selected mood.

I've obviously made a mistake but am not sure where to look to check!


3 Answers

Chris Jones
Chris Jones
Treehouse Guest Teacher

See if this thread helps you. I ran into a similar issue and I think you'll find the answer there.

I have the following code but the image stays as "happy":

        self.mainImageView.image = [UIImage imageWithData:entry.image];
    } else {
        self.mainImageView.image = [UIImage imageNamed:@"icn_noimage"];

    if (entry.mood == BDCDiaryEntryMoodGood){
        self.moodImageView.image = [UIImage imageNamed:@"icn_happy"];
    else if (entry.mood == BDCDiaryEntryMoodAverage) {
        self.moodImageView.image = [UIImage imageNamed:@"icn_average"];
    else if(entry.mood == BDCDiaryEntryMoodBad) {
        self.moodImageView.image = [UIImage imageNamed:@"icn_bad"];

Spot on! :)