当前位置: 动力学知识库 > 问答 > 编程问答 >

xcode - Bind sqlite database with costume iOS framework

问题描述:

I have developed a custom ios framework for achieving some task, which is working perfectly but I have to add my sqlite database separately in my test app. I want to bind my sqlite database with my custom framework so that it will automatically added in any app where user want to user that framework.

I also don't want to show sqlite database to anyone. can anyone please tell me the best way to achieve this.

Thanks in advance

网友答案:

I believe you're looking to ship a sqlite database with your app, and have it installed invisibly to the user. Just add the database to your NSBundle, by including it in the application. The important part is that you must copy this bundled database to the file system (you probably want to also mark it as not being in the cloud), because the NSBundle'd files are read-only. So, here's your strategy: 1) on startup, check to see if the database is in the file system. 2) if not, copy it from the NSBundle to the file system, 3) open the database in the file system.

网友答案:

Maybe there is a better solution to your question but here is a suggestion on what you could: Programmatically create the database in your framework. As for hiding the database here is the solution to that! You may also encrypt the sqlite file.

Cheers

分享给朋友:
您可能感兴趣的文章:
随机阅读: