Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data and iOS 7: Different behavior of persistent store

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?

like image 960
FrankZp Avatar asked Sep 18 '13 10:09

FrankZp


People also ask

What is persistent store in Core Data?

A persistent store is a repository in which managed objects may be stored. You can think of a persistent store as a database data file where individual records each hold the last-saved values of a managed object. Core Data offers three native file types for a persistent store: binary, XML, and SQLite.

What is Core Data stack in iOS?

Overview. After you create a data model file as described in Creating a Core Data Model, set up the classes that collaboratively support your app's model layer. These classes are referred to collectively as the Core Data stack.

Can the persistent store coordinator have multiple persistent stores?

Q: How many Managed Object Model, a Persistent Store Coordinator can have? We can have only one Persistent Store Coordinator for each model.

What is persistent store in iOS?

Data persistence means storing any type of data to disk so that the same data can be retrieved without being altered when the user opens the app next time. We are going to describe all the ways to store data locally in iOS apps.


1 Answers

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:

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

like image 84
Andy Etheridge Avatar answered Sep 23 '22 19:09

Andy Etheridge