Core Data and iOS 7: Different behavior of persistent store

IosSqliteCore DataIos7Uimanageddocument

Ios Problem Overview


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).

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

  • persistentStore
  • persistentStore-wal and
  • persistentStore-shm

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?

Ios Solutions


Solution 1 - Ios

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"} };

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

https://stackoverflow.com/questions/17487306/ios-coredata-are-there-any-disadvantages-to-enabling-sqlite-wal-write-ahead

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFrankZpView Question on Stackoverflow
Solution 1 - IosAndy EtheridgeView Answer on Stackoverflow