テーブル セルを使用する iPhone アプリケーションを作成しています。テーブルからセルを削除するようにこのコードを設定しましたが、NSMutableArray を使用していないため、機能していないようです。スワイプすると削除ボタンが表示されますが、削除ボタンは何もしません。私の質問は、テーブルセルで NSMutableArray を使用していない場合、この行は[self.dataArray removeObjectAtIndex:indexPath.row];
機能しますか?
使用コード
(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES; }
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If your data source is an NSMutableArray, do this
[self.dataArray removeObjectAtIndex:indexPath.row];
} }