Search code examples
iosnsmanagedobjectcontextpersistent-storage

Clear a whole Core Data using NSManagedObjectContext


I am using Core Data in my app,

and maybe my users wants to delete all the NSManagedObjects that they once saved,

So is there a quick method of NSManagedObjectContext that can do this, I mean, clear the whole persistent store, or in another word,delete all objects of every entity, so there's no actual objects (except entities) in core data?

Thanks a lot!


Solution

  • You can either delete everything entity-by-entity or clear the store file itself.

    See this solution: Delete/Reset all entries in Core Data?