Reputation: 225
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:
an empty .sqlite file
a .sqlite-wal file
a .sqlite-shm file.
How do I do import this data into my app?
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.
Upvotes: 3
Views: 2111
Reputation: 39
I can confirm "compacting" the database using the FIREFOX add-on provided by @Lukasz Kowalski herein is confirmed with 10.9.1 / Xcode 5 / iOS 7. To clarify procedure... download Firefox, then get his SQLite Manager add-on.
Copy enclosing StoreContent folder with PersistentStore, PersistentStore-wal and PersistentStore-shm files to desktop for re-combination into single pre-iOS7 UIManagedDocument database that functions as before. where to find:
~/Library/ApplicationSupport/iPhoneSimulator/7.xx/Applications/gobble-d-gook/APPNAME/Documents/APPNAMEDatabase/StoreContent/{your database files}
Launch Firefox, open window, from menu Tools > Sqlite Manager
Upvotes: 2
Reputation: 101
I have found solution to create 1 .sqlite file when you have 3 files: .sqlite, .sqlite-wal and .sqlite-shm. To do that you should use „SQLite Manager” addon for Firefox (https://addons.mozilla.org/pl/firefox/addon/sqlite-manager/?src=userprofile):
Upvotes: 0
Reputation: 225
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.
Cheers
Upvotes: 1
Reputation: 3763
You could also save the JSON in a txt file and on load parse it into Core Data. Depending on how much data you have, you should do this in batches with the first batch being just large enough to populate the first view and then continue parsing the rest. All in a background queue off course. Not as easy as it was before, but this is a solution. Maybe someone else has a better solution?
Upvotes: 0
Reputation: 3763
Try just the sqlite file. See if it works, add the other two one by one.
Upvotes: 0