Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the URL of a Core Data persistent store for deletion?

Tags:

ios

core-data

I wish to call the function persistentStoreCoordinator.destroyPersistentStoreAtURL(...). I'm creating my container with it like this NSPersistentContainer(name: "MyProject") what I would like to know is how to get the URL of the persistentStore for use in the first call, in Swift preferably.

Many thanks.

like image 780
Josh Paradroid Avatar asked Sep 01 '25 02:09

Josh Paradroid


1 Answers

The NSPersistentContainer has a persistentStoreDescriptions property.

That array describes the stores loaded in the coordinator, including their URL.

like image 52
pfandrade Avatar answered Sep 02 '25 16:09

pfandrade