Reputation: 29
I thought I figured out myself how to do this question, but it won't work. The code I used:
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
//timedText = a NSString
[timed replaceObjectAtIndex:1 withObject:timedText];
[SpelerTable reloadData];
}
Can someone tell me what I am doing wrong? Also, I'd like to not use "replaceObjectAtIndex:1" but use the selected cell.
Thanks in advance.
Upvotes: 2
Views: 241
Reputation: 556
Try This code
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
//timedText = a NSString
[timed replaceObjectAtIndex:indexpath.row withObject:timedText];
[SpelerTable reloadData];
}
if everything right in your other code thn it will work.
Upvotes: 0
Reputation: 6590
To use the cell:
UITableViewCell *cell = [self tableView:self.tableView cellForRowAtIndexPath:indexPath];
Upvotes: 0
Reputation: 122401
Why index 1
and not indexPath.row
? Plus you don't need to reload the whole table; just the row that changed:
[timed replaceObjectAtIndex:indexPath.row withObject:timedText];
[spelerTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewAnimationAutomatic];
Upvotes: 1