How to save the content of a MOC to a file, with no -wal and no -shm?

大城市里の小女人 提交于 2019-12-12 14:33:35

问题


I want to save the content of a MOC to a file myFile.ext. Everything works well, my data is saved to the file BUT I have to auxiliary files in addition:

  • myFile.ext-wal
  • myFile.ext-shm

Are these files necessary for my purpose (saving the content of a MOC to a file)? I would like to "ship" my data in only one file. Furthermore, when I get again my data, I only use the URL of myFile.ext.

If they are not necessary, is it possible to avoid their creation?


回答1:


As CL indicated they are necessary in WAL mode. To disable the journaling mode when creating your persistent store pass the flowing option.

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

_coordinator = [_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:options error:&storeError]; 

When you run your app again the -wal should disappear and the -shm can be deleted or ignored. All you data should be in the one sqlite file.




回答2:


These files are created (and are necessary) when the database is in WAL mode.

To disable WAL mode, open the database directly and execute PRAGMA journal_mode = DELETE.



来源:https://stackoverflow.com/questions/24291083/how-to-save-the-content-of-a-moc-to-a-file-with-no-wal-and-no-shm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!