iOS: How to copy pre-seeded database at the first running app with SQLite.swift to writeable location?

懵懂的女人 提交于 2019-12-08 04:13:59

问题


I had the previous question here about database location. What different between store database in different locations in iOS?

I'm confused in copying pre-seeded database to the writable location.

Now, every time I run and build my app, the in-use database will be replaced by pre-seeded db.

And in the future, if I update my app version, how do I prevent the database from being replaced?


回答1:


how do I prevent the database from being replaced?

Check the destination before you copy the database. If there's already a file there, don't do the copy. You can use -[NSFileManager fileExistsAtPath:] to check for an existing file.



来源:https://stackoverflow.com/questions/34614968/ios-how-to-copy-pre-seeded-database-at-the-first-running-app-with-sqlite-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!