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

Double click required on tableview in Ribbit project

I have completed the Ribbit project but when i use the simulator it requires a click on the name I want and then another click in another row for the checkmark to appear or disappear. I have gone through and double checked the code from the Project download but can't find the error. Any help would be appreciated.

Here is the code that I have done for the camera view controller for example.

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

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

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

    PFUser *user = [self.friends objectAtIndex:indexPath.row];

    if (cell.accessoryType == UITableViewCellAccessoryNone) {

    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    [self.recipients addObject:user.objectId];
    

    } else {

    cell.accessoryType = UITableViewCellAccessoryNone;
    [self.recipients removeObject:user.objectId];
    

    }

}

2 Answers

Robert Bojor
PLUS
Robert Bojor
Courses Plus Student 29,439 Points

For me it works, but then again, I am using the MSCellAccessory class to add / remove the check marks.

Try and add [cell setNeedsLayout]; after you are changing the accessoryType and see if it refreshes it correctly - actually you can add it right after that if-else statement finishes.

I actually copied the code from Ben's project into mine which was exactly the same and then it worked fine, so unless something else caused it I am at a loss but I will try your example as well as it would be good to learn a different way...