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

deselectRowAtIndexPath Not Working

I am on the video "Adding Friends By Tapping On A Table View Cell" in the project "Build A Self Destructing Messaging App" and I put in the line:

[self.tableView deselectRowAtIndexPath:indexPath animated:NO];

and it doesn't seem to be working. The selection on the tableView cell still stays blue. This is my code:

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
    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]);

        }    }];

}

4 Answers

Nevermind. I see where i went wrong. I did deselectRowAtIndexPath in the method name

I had the same problem, it sneaks up on ya.

Jerome

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Everybody gets bit by this bug. :)

Good thing I found this...made the same mistake. Autocomplete can be a boon and a bane. :)