Reputation: 16298
I'm trying out CoreData for pretty much the first time, believe it or not.
I will have about 10000 objects of an entity A.
Sometimes I will need to replace all those objects with new ones, about the same amount. Deleting all entities takes a long long time, so I looked around and some people seemed to suggest that if we create a "collection" object that contains all of the other objects, we can just delete the collection and then have Core Data cascade delete the other objects. I haven't been able to do any exact time check so far but it does not feel like this changes anything. Did I miss something?
Upvotes: 0
Views: 252
Reputation: 119031
The simplest option is to tear down your Core Data stack and then delete the data store from disk (preferably by using the persistent store coordinator removePersistentStore:error:
. This only works if you are deleting everything. Afterwards you rerun your code to setup the Core Data stack.
If you need to delete manually then you should batch save the context and you will need to profile to find the best batch size.
Upvotes: 1