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 trialJohn Randak
2,552 PointsDelayed 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);
}
3 Answers
John Randak
2,552 PointsSo 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
9,523 PointsGood find! I totally missed that!
Patrick Donahue
9,523 PointsLooks like you are missing an opening curly brace "{" after if (cell.accessoryType == UITableViewCellAccessoryNone)
John Randak
2,552 Pointsyeah it's in my actual code. I'm not sure why it didn't paste in there. :/
Patrick Donahue
9,523 PointsWeird. It looks like the exact code I have when I did that project except I animate my deselectRow.
Imran Mouna
2,504 PointsImran Mouna
2,504 PointsThank you for posting this! I did the same thing.