When Apple added the new PersistentContainer class, they changed the location of the data stores. That means that if you add a new PersistentContainer, it won't pick up the current database but create one. The underlying issue is that the new store is inside another folder. How can I specify the folder for a PersistentContainer so that it picks up the old store?
The persistent store(s) of a NSPersistentContainer
are specified in its persistentStoreDescriptions
array property. By default, it contains one persistent store of type SQLite, backed by a file in the Application Support
folder of your app's container.
The procedure to change this is explained in the Discussion section of the documentation of this property .
The path to the file of this store is specified in the url
property of the that NSPersistentStoreDescription
, which is mutable. So you should set the url
property of that single NSPersistentStoreDescription
in that array to your desired path.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.