且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS:如何使用SQLite.swift在第一个运行的应用程序中将预种子数据库复制到可写位置?

更新时间:2023-01-19 15:45:52

如何防止数据库被替换?

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.