を、Iは、tableArrays
クラス変数(NSMutableArraysのNSMutableArrayのあることが、以下の方法のUITableViewからセルを削除する - 各セクションの1 NSMutableArrayのを表す - 私のiPhoneアプリでエラー
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [tableArrays count];
}
注とのUITableViewを有します私のテーブルビュー)。さて、のUITableViewは編集をサポートし、私は次のような方法ので
- (void)tableView:(UITableView *)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
...some code...
NSLog(@"tableArrays count is %i",[tableArrays count]);
[tableArrays removeObjectAtIndex:indexPath.section];
NSLog(@"tableArrays is now %@",tableArrays);
NSLog(@"tableArrays count is now %i",[tableArrays count]);
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
を持っていることを、私は、アプリを実行し、私は私のテーブルビューに2つのセクションがあります。行の削除は、セクション内の最後の行を削除する場合を除いて正常に機能します。私は、セクション1の最後の行を削除すると、私は次の出力を参照して、上記のコードに従って:
tableArrays count is 2
tableArrays is now (("Blah1","Blah2"))
tableArrays count is now 1
だから、はっきりと、私のtableArrays
カウントが1ずつ減少が、私は次のエラーを取得する:
...The number of sections contained in the tableView after the update (1) must be qual to the number of sections contained in the table view before the update (2), plus or minus the number of sections inserted or dleted (0 inserted, 0 deleted).'
改訂をご覧ください。 NSMutableArraysのNSMutableArray(tableViewの各セクションの1つのNSMutableArrayを表します) – CodeGuy
が私の答えを更新しました –
これを解決しましたか? –