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 Retrieving and Viewing Data from Parse.com Retrieving Data from Parse.com

John Randak
John Randak
2,552 Points

Delayed Check Mark in UITableView

Hello there! It's getting harder to ask questions as the code is getting more complicated but I'll try. So, I just finished the section that taught us how to select an image and then add recipients. For some reason, on the screen where I can select my recipients, it will only show a checkmark on their name once I've clicked on them and then somewhere else. So I click on name one, and all that happens is that name is highlighted. But then when I click on the second name on the table, the first name is now checked! It's a little bizarre.

I assumed the problem was the code in the didSelectRowAtIndexPath method but I downloaded the practice files and the code is exactly the same. :?

anyway, here's the code:

- (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];
  }
       NSLog(@"%@", self.recipients);
}
Imran Mouna
Imran Mouna
2,504 Points

Thank you for posting this! I did the same thing.

3 Answers

John Randak
John Randak
2,552 Points

So my solution to figuring out what went wrong was to commit my iteration of the file and then copy and paste the exercise file into my InboxViewController so that I could see what if anything contrasted in the version editor. If you look closely in this code, and it took me a while to see it, but I wrote DEselect row at index path.

Ugh. I knew it must be something obvious like that. Silver lining: this is probably a teachable moment. Thanks for taking the time to look over it, Patrick.

Patrick Donahue
Patrick Donahue
9,523 Points

Good find! I totally missed that!

Patrick Donahue
Patrick Donahue
9,523 Points

Looks like you are missing an opening curly brace "{" after if (cell.accessoryType == UITableViewCellAccessoryNone)

John Randak
John Randak
2,552 Points

yeah it's in my actual code. I'm not sure why it didn't paste in there. :/

Patrick Donahue
Patrick Donahue
9,523 Points

Weird. It looks like the exact code I have when I did that project except I animate my deselectRow.