How to delete all data in CoreData?

Is there a quick way to delete all the data in my CoreData without calling deleteObject for each object in the model?

+3
source share
2 answers

Delete persistent storage on disk (after calling -[NSPersistentStoreCoordinator removePersistentStore:error:]for any permanent storage coordinator that references the storage). You probably also want to reset any instances NSManagedObjectContextthat can have instances of object instances from this repository before deleting and deleting the repository on disk.

+2
source

You can free all yours NSPersistentStoreCoordinatorand everything that you have NSManagedObjectContest, then delete the file in FS and recreate it.

0

Source: https://habr.com/ru/post/1722082/


All Articles