How I could completely clear out EVERYTHING in a Core Data model i.e remove all objects for all entities?
I will be using the code to clear out the saved history in a the model.
Here is another way to do...
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSFetchRequest * allMovies = [[NSFetchRequest alloc] init];
[allMovies setEntity:[NSEntityDescription entityForName:@"Movies" inManagedObjectContext:context]];
[allMovies setIncludesPropertyValues:NO]; //only fetch the managedObjectID
NSError * error = nil;
NSArray * movies = [context executeFetchRequest:allMovies error:&error];
//error handling goes here
for (NSManagedObject * movie in movies) {
[context deleteObject:movie];
}
NSError *saveError = nil;
[context save:&saveError];
It will clear all the objects.
Delete the .sqlite DB Core Data creates (it's probably stored on your /Documents directory) and get your app to re-create it.
Here is a good answer to this question.
Delete/Reset all entries in Core Data?
Then just make sure to re-create the store.