sqlite database disk image malformed on iPhone SDK

前端 未结 3 1805
無奈伤痛
無奈伤痛 2021-01-12 07:58

I\'m having an issue with a new application on the iPhone SDK using SQLite as the DB backend.

Occasionally, my app will stop loading data to my UITableViews and afte

3条回答
  •  旧巷少年郎
    2021-01-12 08:53

    In my case this had to do with iOS 7: On iOS 7 Core Data now uses the SQLite WAL journaling mode which writes data to a .db-wal file instead of directly to the .db file. In my app, I would copy a prepared .db file into Library/Application Support during an app update. The problem was that an old .db-wal file was still in that directory and I only replaced the .db file. That way, I ended up with a .db file that was out of sync with the old .db-wal file.

    There are two solutions to this problem:

    1. Make sure the .db, .db-wal and .db-shm files are deleted before you copy your new .db file into place.
    2. Go back to the old pre-iOS 7 behavior like so: https://stackoverflow.com/a/18870738/171933

提交回复
热议问题