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

Friends List Not Updating Dynamically

I finished the "Relating Users in Parse.com" section of this project. I see the result that Ben displays in the app at the end of the last video. As I check and uncheck table view cells, the data browser in the backend updates accordingly.

But, when I navigate back to the Friends View Controller, my selections or deselections do not change anything locally on the app. This means that a new user, even after selecting friends, essentially remains with an empty Friends Table View.

The following are my implementations for didSelectRowAtIndexPath and isFriend methods, as that is where I think the problem is. I update the self.friends mutable array property accordingly as well, so I don't quite know what's going wrong.

'''

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

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    PFUser *user = self.allUsers[indexPath.row]; PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"];

    if ([self isFriend:user]) { cell.accessoryType = UITableViewCellAccessoryNone; for (PFUser *friend in self.friends) { if ([friend.objectId isEqualToString:user.objectId]) { [self.friends removeObject:friend]; break; } } [friendsRelation removeObject:user]; } else { cell.accessoryType = UITableViewCellAccessoryCheckmark; [self.friends addObject:user]; [friendsRelation addObject:user]; } [self.currentUser saveInBackgroundWithBlock: ^(BOOL succeeded, NSError *error) { if (error) { NSLog(@"Error %@ %@", error, error.userInfo); } }]; }

    pragma mark - Helper Methods

    • (BOOL)isFriend:(PFUser *)user { for (PFUser *friend in self.friends) { if ([friend.objectId isEqualToString:user.objectId]) { return YES; } } return NO; } '''

Thanks for the help in advance

2 Answers

Yes, it was resolved in the following thread https://teamtreehouse.com/forum/friend-lists-are-not-updating, which asked the same question after I originally did. At the bottom of the video, there is a note that there is a known error. That error is fixed both in the next stage and pointed out at the beginning of the next stage of the project, which involves giving the app a custom design.

Great. I hope to get through the profile page and then move on to fixing this issue!

Maybe you could mark your answer as the best and then others will be able to find that helpful information! Thanks for the reply. I really appreciate it.

have you sorted this out? I am also having this issue. friend changes are only reflected if i restart the app.