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

查看:29
本文介绍了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).

在 iOS 7 版本(全新安装)中,持久存储现在有三个文件:

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

  • persistentStore
  • persistentStore-wal
  • 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 添加到选项来指定日志模式.例如.设置以前的默认删除模式:

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 Logging 的任何缺点

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

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