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

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...