私は NSFetchedResultsController を使用していますが、現在の問題を解決する方法がわかりません。テーブル ビューのヘッダーは、実際のヘッダーではなくセルです。これは、スクロール中にヘッダーが上部にくっつかないようにするためです。
メッセージはそれについて非常に明確です:
CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). with userInfo (null)
ただし、1 行挿入後のセクションの行数は 2 である必要があります。テーブルビューにこれを知らせるにはどうすればよいですか? 私はすでに次のようなことをしています:
indexPath = [NSIndexPath indexPathForRow:indexPath.row + 1
inSection:section];
newIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row + 1
inSection:section];
ただし、この特定のケースでは機能しません。最初のクラッシュの後、すべてが正常に機能します。これは、コア データ自体から 1 つだけが挿入され、2 つのセルが挿入されるのはそのときだけであるためです。