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

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

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

发布评论

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

>www.elefans.com

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