最初は私のテーブルビューが空ですが、次に独自のセルを追加できます。これらのセルを削除すると、すべてが正常に機能します。ただし、最後のセルを削除すると、NSMutableArrayにオブジェクトが含まれなくなり、コンソールでこのエラーが発生します(また、コアデータを使用してセルを保存しています)。
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[_PFBatchFaultingArray objectAtIndex:]: index (123150308) beyond bounds (1)'
このコード行も入れてみましたが、それでも同じ結果が得られます。
//arr is my mutable array
if ([arr count] == 0) {
NSLog(@"No Cells");
}
これは、テーブルビューからオブジェクトを削除する方法です。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[arr removeObjectAtIndex:0];
[context deleteObject:[arr objectAtIndex:0]];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
この問題をどのように解決しますか?