views:

14

answers:

1

Hi,

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.

Thanks for any hints

A: 

To delete the persistent store, you need to close down the Core Data stack, delete the persistent store and then rebuild it the stack.

I would just use the tableview's beginUpdate method to freeze the table, then nil out the fetchedResults controller, then the Core Data stack. Delete the persistent store then rebuild the stack and create a new fetched results controller. Then tell the `endUpdate' and then tell the table to reload data. That should all take brief time unnoticeable by the user.

TechZen
thanks for your help, problem solved!
Nico