0

What I have found in most of the solution for deleting all entries from core data, is three step process:

  1. Fetch them all

  2. Delete them all

  3. Save them all

Is there any alternative ...?

Sailendra
  • 1,316
  • 13
  • 26
Roshan Sah
  • 129
  • 10
  • 1
    you can find more detail regarding delete all record here http://stackoverflow.com/questions/1383598/core-data-quickest-way-to-delete-all-instances-of-an-entity – CodeChanger Nov 07 '16 at 06:53

1 Answers1

5
NSFetchRequest *requestDelete = [[NSFetchRequest alloc] initWithEntityName:@"Car"];
NSBatchDeleteRequest *deleteEntity = [[NSBatchDeleteRequest alloc] initWithFetchRequest:requestDelete];

NSError *deleteError = nil;
[myPersistentStoreCoordinator executeRequest:deleteEntity withContext:myContext error:&deleteError];

iOS 9 added a new class called NSBatchDeleteRequest that allows you to easily delete objects matching a predicate without having to load them all in to memory.

Narendra Pandey
  • 672
  • 9
  • 28