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

parse.com cant create a relation

" Build a Self-Destructing Message iPhone App " Im trying to program a many-to-many relation, doing it as the documentation shows (and the video here). Im trying to check friends then i hit the "back" button and it shows nothing. so i checked the the "friendRelation" column and i have no relation with any of the other user ive created. the relevant code is:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    self.currentUser = [PFUser currentUser];
    PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"];
    PFUser *otherUser = [self.allUsers objectAtIndex:indexPath.row];
    [friendsRelation addObject: otherUser];
    [self.currentUser saveInBackground];

Thanks for the help

1 Answer

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Hi Amit,

I think this might be related to a bug in the code. In FriendsViewController and CameraViewController, I am setting friendsRelation in the viewDidLoad method. That line needs to move to viewWillAppear, however. I recorded a fix in the next project (which will be a continuation of this one).

Sorry for the confusion! Hopefully that fixes it for you. I'll add a note to that video, too.