I am trying to update a UITableViewCell when it is tapped for a little feedback like so:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[self.menuItems objectAtIndex:aPath.row] isEqualToString:@"AirPrint Order"]) {
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.textLabel.text=@"Generating Order Receipt";
NSArray *nsa = [[NSArray alloc] initWithObjects:indexPath, nil];
[tableView reloadRowsAtIndexPaths:nsa withRowAnimation:UITableViewRowAnimationNone];
}
}
This code seems to do nothing even though in the debugger it does make it inside my if statement but nothing is happening with the cell text.
When you call
reloadRowsAtIndexPathsit actually callscellForRowAtIndexPath:again and reloads the cell, removing the changes that you applied to it indidSelectRowAtIndexPath. What I advise you to do is: update your data in thedidSelectRowAtIndexPathmethod and read it incellForRowAtIndexPath.