如何将MOC的内容保存到文件,没有-wal和没有-shm? [英] How to save the content of a MOC to a file, with no -wal and no -shm?

查看:247
本文介绍了如何将MOC的内容保存到文件,没有-wal和没有-shm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要将 MOC 的内容保存到文件 myFile.ext 。一切都很好,我的数据保存到文件BUT我还要辅助文件:

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

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

这些文件是否为我的目的所需(将 MOC 的内容保存到文件)?我想只在一个文件我的数据。此外,当我再次获得我的数据时,我只使用 myFile.ext URL

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?

推荐答案

由于CL表示它们在WAL模式下是必需的。要在创建持久存储时禁用日志模式,请传递流动选项。

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]; 

再次运行应用程序时,-wal应该会消失,可以删除或忽略-shm。所有的数据应该在一个sqlite文件中。

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.

这篇关于如何将MOC的内容保存到文件,没有-wal和没有-shm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆