Core Data和iOS 7:持久存储的不同行为 [英] Core Data and iOS 7: Different behavior of persistent store

查看:135
本文介绍了Core Data和iOS 7:持久存储的不同行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为基于Core Data的应用程序准备iOS 7的修补程序的更新。我使用Xcode 5和iOS 7 SDK GM。然而,我意识到持久存储的不同行为(这是一个 UIManagedDocument ):在iOS 7构建之前,只有一个文件 persistentStore 在文档文件夹(有时有第二个 persistentStore-journal )。

I'm preparing an update for a Core Data based app for fixes with iOS 7. I use Xcode 5 and iOS 7 SDK GM. However I realized a different behavior of the persistent store (which is a UIManagedDocument): Prior to iOS 7 builds there was only one file persistentStore in the documents folder (sometimes there was a second one persistentStore-journal).

7 builds(clean installation)现在有三个文件用于永久存储:

In iOS 7 builds (clean installation) there are now three files for the persistent store:


  • persistentStore

  • persistentStore-wal

  • persistentStore-shm

  • persistentStore
  • persistentStore-wal and
  • persistentStore-shm

Apple现在是否将日志模式更改为WAL?我想知道是否有影响我的应用程序(想想用户如何更新从上一个版本)?最好禁用WAL - 如果是,我该如何使用iOS 7 / UIManagedDocument

Did Apple change the journal mode by default to WAL now? I wonder if there is an impact on my app (think of users how update from the last version)? Would it be best to disable WAL - and if so, how can I do this with iOS 7/UIManagedDocument?

推荐答案

是的,Apple已经将iOS7的默认日记帐模式更改为WAL。
在调用addPersistentStoreWithType:configuration:url:options:error时,可以通过将NSSQLitePragmasOption添加到选项中来指定日志模式。例如。设置以前的默认模式DELETE:

Yes, Apple have changed the default journal mode to WAL for iOS7. You can specify the journal mode by adding the NSSQLitePragmasOption to the options when calling addPersistentStoreWithType:configuration:url:options:error. E.g. to set the previous default mode of DELETE:

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

在我的经验中,WAL提供更好的性能,但也看到这篇文章:

In my experience WAL gives better performance, but also see this post:

iOS CoreData - 启用sqlite WAL / Write-Ahead记录有什么缺点

iOS CoreData - are there any disadvantages to enabling sqlite WAL / Write-Ahead Logging

这篇关于Core Data和iOS 7:持久存储的不同行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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