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
Bill Walker
5,951 PointsAdding Friends by Tapping on a Table View Cell - Build a Self-Destructing Message iPhone App
I've just finished the Adding Friends by Tapping on a Table View Cell video and when running the app in the simulator, tapping on friends highlights the cell, but it does not deselect itself nor does it add the checkmark until AFTER I select a different cell. I've looked over my code and as far as I can tell, it matches what is in the video:
- (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);
}
}];
}
Any insight on what's going on? I'm using Xcode 5.0.2 and targeting iOS7.
2 Answers
Bill Walker
5,951 PointsD'oh! Figured out my mistake. I used did*DeselectRowAtIndexPath instead of didSelect*RowAtIndexPath
Douglas Rogers
2,619 PointsFantastic! I was wondering why this wasn't working. Maybe a text-popup added to the video could prevent this. I could have sworn i saw the Deselect version of the method in the video
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherThe perils of autocomplete! I have made that same mistake before. :)