I’ve got a weird problem, when I add new usernames to a tableView and insert it the following way (if I just simply reload the table data it doesn’t happen), the names always “appear” the same as the username at index 0. When I switch views and come back to the tableView everything is ok, the new username changed it’s name “back to its supposed name”. Maybe I’m doing something wrong with the NSIndexPath? Hope someone can help. Thank you!
NSIndexPath *path1 = [NSIndexPath indexPathForRow:0 inSection:0];
NSArray *indexArray = [NSArray arrayWithObjects:path1,nil];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexArraywithRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
You need to insert the row at the index path where the new name should be, not at row 0. So, if you did something like
[self.mutableNames insertObject:@"name" atIndex:4]to add the name to your data, then you’d want to create the index path for the row you insert like[NSIndexPath indexPathForRow:4 inSection:0].