iOS:如何使用SQLite.swift在第一个运行的应用程序中将预种子数据库复制到可写位置? [英] iOS: How to copy pre-seeded database at the first running app with SQLite.swift to writeable location?

查看:82
本文介绍了iOS:如何使用SQLite.swift在第一个运行的应用程序中将预种子数据库复制到可写位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有关于数据库位置的上一个问题. iOS中不同位置的商店数据库之间有何不同?

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?

推荐答案

如何防止数据库被替换?

how do I prevent the database from being replaced?

在复制数据库之前检查目标.如果那里已经有文件,请不要进行复制.您可以使用-[NSFileManager fileExistsAtPath:]检查现有文件.

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.

这篇关于iOS:如何使用SQLite.swift在第一个运行的应用程序中将预种子数据库复制到可写位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆