Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Self-Destructing Message iPhone App Relating Users in Parse.com Adding the Edit Friends Screen

Relations User in Parse.com

Hey Guy!! I am trying to follow the Relating Users in Parse.com video. I did all that Ben said and I did not find any failed although I can not see my friends in any list.

What can be wrong in this code?

// // EditFriendsTableViewController.h // Ribbit // // Created by mlabarga on 31/07/14. // Copyright (c) 2014 mayte. All rights reserved. //

import <UIKit/UIKit.h>

import <Parse/Parse.h>

@interface EditFriendsTableViewController : UITableViewController

@property (nonatomic, strong) NSArray *allUsers; @property (nonatomic, strong) PFUser *currentUser;


// // EditFriendsTableViewController.m // Ribbit // // Created by mlabarga on 31/07/14. // Copyright (c) 2014 mayte. All rights reserved. //

import "EditFriendsTableViewController.h"

import <Parse/Parse.h>

@interface EditFriendsTableViewController ()


@implementation EditFriendsTableViewController

  • (void)viewDidLoad { [super viewDidLoad]; PFQuery *query =[PFUser query]; [query orderByAscending:@"username"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (error) { NSLog(@"Error: %@ %@",error, [error userInfo]); } else { self.allUsers = objects; [self.tableView reloadData]; } }]; }

pragma mark - Table view data source

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self.allUsers count]; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier =@"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; cell.textLabel.text =user.username; return cell; }

pragma mark - Table view delegate

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark;

    PFRelation *friendsRelation = [self.currentUser relationForKey:@"friendsRelation"]; PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; [friendsRelation addObject:user]; [self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (error) { NSLog(@"Error: %@ %@", error, [error userInfo]); } }];



Thank you for your help!!! I am really frustrated

3 Answers


Do you see any potential friends when you click 'Edit Friends'? Are there some users to select?

If not, check Parse - are they there?

If you have selected some friends but can't see them on your Friends list, let's look at your FriendsViewController files.


Hi Steve. Thank you so much for your help. At the end, you are right. I had a problem with Friends. I was writing "Cell" twice (in friends and edit friends.

Once again, thanks. Have a nice day.

Glad you got it sorted!! ;-)