1

I am using an UITableViewController containing a UITableView and an UISearchTableView. The table lists e.g. 1000 entries. I want to provide the user a button to delete all entries of a specific entity. Because looping over all managed objects and saving the context takes a very long time, I thought of deleting by removing the persistent store and rebuilding the stack.

Now to my questions: How can I do this in the UITableViewController? I don't want to restart the app for deletion so I want to move the code from the app delegate.

4

1 に答える 1

0

永続ストアを削除するには、Core Dataスタックを閉じ、永続ストアを削除してから、スタックを再構築する必要があります。

テーブルビューのbeginUpdateメソッドを使用してテーブルをフリーズし、fetchedResultsコントローラーをゼロにしてから、CoreDataスタックを削除します。永続ストアを削除してからスタックを再構築し、フェッチされた新しい結果コントローラーを作成します。次に、 `endUpdate'に指示してから、データをリロードするようにテーブルに指示します。それはすべて、ユーザーが気付かないほど短い時間かかるはずです。

于 2010-10-17T19:43:57.680 に答える