I’m developing an iPad Application, in which one of the screens has an embedded tableview with multiple sections. Each section is populated by its own array (array1, and array2).
I’ve created a button that puts this table into editting mode. However, I need to change my
$tableView:commitEditingStyle:forRowAtIndexPath
somehow to determine what section the selected row is in, and delete the entry from the associated array as well. Does anyone have any ideas?
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if(editingStyle == UITableViewCellEditingStyleDelete){
//This is the line i need to change...
[array1 removeObjectAtIndex:indexPath.row];
[myTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
Looks like you need to remove the row from the correct array… using a switch statement on the sections might work (but only if there’s a set number of sections, which you seem to indicate there is)
So where you’re removing the object from the array, make sure you’re removing it from the correct array based on the section.
etc.