如何使用sqlite文件将数据预加载到iOS应用程序 [英] How to preload data into an iOS app using sqlite files
问题描述
在新的 Xcode 5
构建之前,我能够通过引用项目中的文件将数据预加载到我的核心数据驱动的应用程序中。但是,自从我升级了 XCode
之后,我的json数据现在被保存为3个文件:
Prior to the new Xcode 5
build, I was able to preload data into my core data powered app by referencing the file from the project. However, ever since I upgraded my XCode
, my json data is now being saved into 3 files:
-
一个空的.sqlite文件
an empty .sqlite file
一个.sqlite-wal文件
a .sqlite-wal file
一个.sqlite-shm文件。
a .sqlite-shm file.
如何将这些资料汇入我的应用程式?
How do I do import this data into my app?
过去,我只需要复制 sqlite
文件即可。现在,我不知道我应该复制什么文件。
In the past all I had to do was copy the sqlite
file and I was done. Now, I have no idea what file I'm supposed to copy.
推荐答案
我发现从苹果的开发人员网站,要让核心数据以旧方式),并且只生成sqlite文件,我不得不添加到persistStore addStore方法,在options参数下。
I found out from apple's developer site that in oder to get core data to behave in the old way (pre-iOS 7), and generate just the sqlite file, I had to add this to the persistentStore addStore method, under the options parameter.
@{ NSSQLitePragmasOption : @{ @"journal_mode" : @"DELETE" } }
否则谁遇到这个问题。
I hope this helps anyone else who encounters this problem.
干杯
这篇关于如何使用sqlite文件将数据预加载到iOS应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!