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

General Discussion

Diary App

On my diary app when you change the mood nothing happens. The icon in the table view is still happy no matter what mood you select. I downloaded the project files from the final stage and it didn't work there either. Any help?

This same thing has happened to me. I've gone over the videos over and over. Everything works except the image changing on my cell. And unfortunately, Ash Furrow never clicked bad or average in the video to confirm that his code worked appropriately. Also, you're right, it doesn't work in the provided project files.

Ash Furrow
Ash Furrow
Treehouse Guest Teacher

Let me take a look and get back to you.

Ash Furrow
Ash Furrow
Treehouse Guest Teacher

What's the link to the demo project? It's working for me locally.

This is the file that I'm personally having issues with. To my knowledge, it's the final of the project files provided for the Diary app. I got it's link from the final video from the "Custom Detail View Controller" section. Here's the link: http://treehouse-code-samples.s3.amazonaws.com/iOS7/DiaryApp/Diary-Stage6-Video5.zip

Any luck figuring this out?

After spending some time with the files again, I'm realizing that when built in the 3.5in and 4in (non 64bit), the program runs, but when adding a new entry the mood selection does not respond. However, when editing the moods after they've been entered you can in fact change the mood. In the 4in 64 bit build, however, the app crashes when clicking the add button, specifically on the line '''_pickedMood = pickedMood;'''.

When I have time later this afternoon, I plan to spend some time dissecting the edit method and seeing if I can get what works there to work appropriately during the add entry method.

2 Answers

Hi guys. I'm sure some of you have noticed that the mood is 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];
   }
}

Updated my answer I created a solution for you guys.

Ash Furrow
Ash Furrow
Treehouse Guest Teacher

Yeah, apologies for that omission.

No worries Ash, it's good to have a challenge from time to time.. awesome job with the course. I really enjoyed it.

Can anyone tell me how to do this part in Swift. I have created the rest of the app. I think I am wrongly implementing instance variable of enum.

         var pickedMood: DiaryEntryMood! {
          didSet {
        self.badButton.alpha = 0.5
        self.averageButton.alpha = 0.5
        self.goodButton.alpha = 0.5

        switch pickedMood! {
        case DiaryEntryMood.DiaryEntryMoodGood:
            self.goodButton.alpha = 1.0
            break
        case DiaryEntryMood.DiaryEntryMoodAverage:
            self.averageButton.alpha = 1.0
            break
        case DiaryEntryMood.DiaryEntryMoodBad:
            self.badButton.alpha = 1.0
            break
        }
    }
} 

Here is one of the button:

                  @IBAction func badWasPressed(sender: AnyObject) {
                     self.pickedMood = DiaryEntryMood.DiaryEntryMoodBad
                  }