LoginSignup
27
27

More than 5 years have passed since last update.

iOS7になったら.sqliteのファイルが見れなくなってしまった

Last updated at Posted at 2013-10-19

iOS7になったらSQLITEの仕様が変更になったらしく、シュミレーターに保存してあったsqliteファイルのデータをSQLite Database Browserで見られなくなってしまった。

こちらに回答が載っていたのでそのまま実施。
http://stackoverflow.com/questions/18870387/core-data-and-ios-7-different-behavior-of-persistent-store
どうやらiOS7からはWALモードになったらしい。SQLite Database BrowserだとWALモードは見れないのだと思う。(あんまりわかってない。)

リンク先の回答者はWALを推奨していたけど、プロトタイプの状態ではデータベースが見られないと不便なので、一時的に変更する。
具体的なコードは以下。

NSDictionary *options = @{NSSQLitePragmasOption: @{@"journal_mode": @"DELETE"}};

このoptionsをaddPersistentStoreWithType:configuration:url:options:errorのoptionに指定するだけ。
これで以前のジャーナルモードに戻るらしい。
以上でSQLite Database BrowserでSQLiteのデータが見られるようになった。

27
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
27