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 trialalex molineaux
4,367 PointsCode Challenge: Removing Friends by Tapping on a Table View Cell 2 of 3
Hi I have got myself a little stuck and cannot progress - any help would be really appreciated.
This was one of my many guesses, golly i really feel that I have not learnt a thing….
import "FavoriteMoviesViewController.h"
@implementation FavoriteMoviesViewController
-
(void)addVideoToPlaylist:(PFObject *)video { // Add custom code below!
PFRelation *relation = [self.playlist relationforKey:@"videos"];
[self.video addObject:relation];
}
@end
1 Answer
Dale Rivera
17,106 PointsYou are really close!
You just switched video and relation.
A good way to think about this challenge is thinking about how it is phrased. You should: "add the 'video' that is passed into the method to the 'relation' variable."
Translated to code this statement is:
[relation addObject:video];
A more complete picture of the answer is this:
#import "FavoriteMoviesViewController.h"
@implementation FavoriteMoviesViewController
- (void)addVideoToPlaylist:(PFObject *)video {
// Add custom code below!
PFRelation *relation = [self.playlist relationforKey:@"videos"];
[relation addObject:video];
}
@end
So you should add the video to the PFRelation relation. What you are currently doing attempts to add the relation to the video which isn't correct.
It is also important to note the difference between instance variables and method variables. Here, we are writing code inside of a method that takes in a video parameter. To access this, we simply refer to the name of the parameter, that is, we just use
video
in our code. Instance variables are accessible throughout a class, and are accessed with the ```
self