Ok, I have a a UITableView and it's being populated with data from a SQLite database. Just as an example, my TableView has three rows and looks like this when it's loaded initially:
Hats
Coats
Shirts
Then when I click the Edit button, the minus sign comes up and they look like this:
- Hats
- Coats
- Shirts
When I click the - sign next to Coats, the following code runs:
Now here's the problem... my Coats item gets deleted, and Shirts bumps up into its place. But Shirts also appears right under it as well. It looks like this:
- Hats
- Shirts
- Shirts
What the hell? Why does a second Shirts appear? Also, when I close my program and reopen it, its displayed correctly now, with just Hats and Shirts (2 items).
How do I make my TableView reload or refresh with the correct data? Why isn't the third row getting deleted?
Ethan
Hats
Coats
Shirts
Then when I click the Edit button, the minus sign comes up and they look like this:
- Hats
- Coats
- Shirts
When I click the - sign next to Coats, the following code runs:
Code:
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// SQL "Delete" code goes here and it works. The item is deleted from my DB
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
}
}
Now here's the problem... my Coats item gets deleted, and Shirts bumps up into its place. But Shirts also appears right under it as well. It looks like this:
- Hats
- Shirts
- Shirts
What the hell? Why does a second Shirts appear? Also, when I close my program and reopen it, its displayed correctly now, with just Hats and Shirts (2 items).
How do I make my TableView reload or refresh with the correct data? Why isn't the third row getting deleted?
Ethan