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 Self-Destructing Message iPhone App Relating Users in Parse.com Removing Friends by Tapping on a Table View Cell

Save "playlist" in background... LOST!

I have no doubt I'm missing something easy, but for the life of me I can not figure out how do solve the last questions stating:

"Finally, we need to save these changes up to the Parse back-end. The relation is part of the playlist property, where playlist is an instance of PFObject. Save playlist in the background to save the changes to the relation (don't worry about using any blocks)." Not sure what method to call!!!

FavoriteMoviesViewController.m
#import "FavoriteMoviesViewController.h"

@implementation FavoriteMoviesViewController

- (void)addVideoToPlaylist:(PFObject *)video {
    // Add custom code below!
    PFRelation *relation = [[self playlist] relationForKey:@"videos"];
    [relation addObject:video];
    [relation saveInBackground:^(BOOL succeeded, NSError *error) {}];
}

@end
Dylan Shine
Dylan Shine
17,565 Points

If you're not trying to use any blocks, try [self.playlist saveInBackground];

You the man @Dylan Shine! You were close... [relation saveInBackground] didn't work but [self.playlist saveInBackground]; was the fix! self.playlist makes sense since that is the array needing to be saved on Parse.

The question was not worded well IMO and my original "saveInBackground" was a guess for sure especially with no example in the video that I saw. The need for these types of major guesses during the code challenge is slightly frustrating. However, the fact that I was trying do this challenge at 1AM probably didn't help my clarity either. :)

1 Answer

We came up with the full answer to the code challenge to look like this:

import "FavoriteMoviesViewController.h"

@implementation FavoriteMoviesViewController

  • (void)addVideoToPlaylist:(PFObject *)video { PFRelation *relation = [[self playlist] relationForKey:@"videos"]; [relation addObject:video]; [self.playlist saveInBackground]; }

@end

Dylan Shine
Dylan Shine
17,565 Points

That makes 100% sense, if the Playlist is your PFObject, then that is what needs to get written to Parse.