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

Diary App Fix for Mood Buttons

Hi guys. I'm sure some of you have noticed that the mood buttons are not working as expected. Just add the 2 lines of code below.

The Fix.

EntryViewController

-(void)insertDiaryEntry {
    MavCoreDataStack *coreDataStack = [MavCoreDataStack defaultStack];
    MavDiaryEntry *entry = [NSEntityDescription insertNewObjectForEntityForName:@"MavDiaryEntry" inManagedObjectContext:coreDataStack.managedObjectContext];
    entry.body = self.textView.text;
    entry.date = [[NSDate date] timeIntervalSince1970];
    entry.imageData = UIImageJPEGRepresentation(self.pickedImage, 0.75);
    entry.location = self.location;
    entry.mood = self.pickedMood; //Add this line
    [coreDataStack saveContext];

//AND

-(void)updateDiaryEntry {
    self.entry.body = self.textView.text;

    self.entry.imageData = UIImageJPEGRepresentation(self.pickedImage, 0.75);
    self.entry.mood = self.pickedMood; //Add this line
    MavCoreDataStack *coreDataStack = [MavCoreDataStack defaultStack];
    [coreDataStack saveContext];

}

}

4 Answers

Yeah, Its not the only thing missing in the video, but it is one of the bigger issues.

Thomas Nilsen
Thomas Nilsen
14,957 Points

Here is another issue with the project that someone else discovered: https://teamtreehouse.com/forum/saving-images-the-diary-app

Patrick Serrano
Patrick Serrano
13,834 Points

I was going to post this yesterday but forgot. I'm glad to see that I wasn't the only one with those two lines missing in my project.

Thanks Thomas I noticed that one too, nice fix!