我有一个静态的 NSMutableArray,这个数组是我的 TableView 的数据源。然后我从我的 TableView 中删除了一个单元格,它崩溃了。
这里是我创建数组的地方:
static NSMutableArray *listaPiscinas;
我的代码:
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[listaPiscinas removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
[TratamentoView setListaPiscinas:listaPiscinas];
NSString *URLdeletarPiscina = [[NSString alloc] initWithFormat:@"%@app/excluir_piscina.php?cod_cliente_piscina=%@", URL_CADASTRO, [[listaPiscinas objectAtIndex:indexPath.row] objectForKey:@"cod_cliente_piscina"]];
dataReciever = [[AsyncDownloader alloc] initWithGetAdress:URLdeletarPiscina delegate:self];
[tableView reloadData];
}
}
最佳答案
虽然您的变量类型为 NSMutableArray,但分配给它的对象是 NSArray,无法更改。
为了进一步帮助您向我们展示创建 listaPiscinas
的代码。
关于ios - "-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21193615/