Core Data 和 iOS 7:持久化存储的不同行为

编程入门 行业动态 更新时间:2024-10-21 19:31:37
本文介绍了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:持久化存储的不同行为

本文发布于:2023-11-15 23:26:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598895.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:持久   Core   Data   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!