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

Steve.

3 Answers

Chris Jones
STAFF
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":

    if(entry.image){
        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! :)