core-data-migration

Detecting a Lightweight Core Data Migration

一世执手 提交于 2019-11-27 09:41:49
问题 I'm using Core Data's automatic lightweight migration successfully. However, when a particular entity gets created during a migration, I'd like to populate it with some data. Of course I could check if the entity is empty every time the application starts, but this seems inefficient when Core Data has a migration framework. Is it possible to detect when a lightweight migration occurs (possibly using KVO or notifications), or does this require implementing standard migrations? I've tried using

iPhone Core Data “Automatic Lightweight Migration”

拈花ヽ惹草 提交于 2019-11-26 23:27:38
I am attempting to update an app that implements a core data store. I am adding an attribute to one of the entities. I added the following code to my delegate class: - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Shoppee.sqlite"]]; NSError *error = nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; NSDictionary

Example or explanation of Core Data Migration with multiple passes?

巧了我就是萌 提交于 2019-11-26 11:59:01
My iPhone app needs to migrate its core data store, and some of the databases are quite large. Apple's documentation suggests using "multiple passes" to migrate data to reduce memory use. However, the documentation is very limited and doesn't explain very well how to actually do this. Can someone either point me towards a good example, or explain in detail the process of how to actually pull this off? Nick Weaver I've figured out what Apple hints in their documentation . It's actually very easy but a long way to go before it's obvious. I'll illustrate the explanation with an example. The

iPhone Core Data “Automatic Lightweight Migration”

一笑奈何 提交于 2019-11-26 08:40:17
问题 I am attempting to update an app that implements a core data store. I am adding an attribute to one of the entities. I added the following code to my delegate class: - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @\"Shoppee.sqlite\"]]; NSError *error = nil; persistentStoreCoordinator = [

Example or explanation of Core Data Migration with multiple passes?

寵の児 提交于 2019-11-26 02:26:46
问题 My iPhone app needs to migrate its core data store, and some of the databases are quite large. Apple\'s documentation suggests using \"multiple passes\" to migrate data to reduce memory use. However, the documentation is very limited and doesn\'t explain very well how to actually do this. Can someone either point me towards a good example, or explain in detail the process of how to actually pull this off? 回答1: I've figured out what Apple hints in their documentation. It's actually very easy