core-data-migration

How to show migration progress of NSMigrationManager in a UILabel?

泄露秘密 提交于 2019-12-09 23:52:45
问题 I have a lot of binary data on Core Data which I would like to remove and save as files so I setup the code so that it would run a manual migration. The problem is that because I have to pull binary from Core Data and save them to files, the migration process could take a very long time depending on how much data there is. I would like to show a simple progress label so that users wouldn't think that the app is frozen. // app did launch - (BOOL)application:(UIApplication *)application

core data manual migration

[亡魂溺海] 提交于 2019-12-09 21:20:20
问题 I'm trying to migrate to a new completely different model in my project. The changes are way too much for a lightweight migration and I think the best way is to iterate through the top level objects and set all the attributes and relationships myself. How can I set up the migration process to be completely manual like this. I've looked into NSMigrationManager which seems to require an NSMappingModel. The only examples and tutorials I've seen use inferredMappingModelForSourceModel

How to switch from Core Data automatic lightweight migration to manual?

送分小仙女□ 提交于 2019-12-08 12:46:37
问题 My situation is similar to this question. I am using lightweight migration with the following code, fairly vanilla from Apple docs and other SO threads. It runs upon app startup when initializing the Core Data stack. NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; NSError *error = nil; NSString *storeType = nil; if (USE

Where to Put Code Configuring Persistent Store for Migration

纵饮孤独 提交于 2019-12-08 12:13:47
问题 I have a Mac App already created and distributed on the App Store to many customers, and I need to add an attribute to the Core Data Model. I read the documentation provided by Apple, available here. However, it gives this block of code to enable automatic migration: NSError *error; NSPersistentStoreCoordinator *psc = <#The coordinator#>; NSURL *storeURL = <#The URL of a persistent store#>; NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]

can a dataModel of Coredata be part of any other bundle than main bundle

末鹿安然 提交于 2019-12-08 05:40:27
I have a datamodel file "Abcde.xcdatamodeld" . It is currently a part of my main bundle and I am referencing it by using the following code. - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel_ != nil) { return managedObjectModel_; } NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"Abcde" ofType:@"momd"]; NSURL *modelURL = [NSURL fileURLWithPath:modelPath]; managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; return managedObjectModel_; } Now I have a requirement where in the "Abcde.xcdatamodeld" should be made to be a part of a

can a dataModel of Coredata be part of any other bundle than main bundle

孤者浪人 提交于 2019-12-08 05:04:22
问题 I have a datamodel file "Abcde.xcdatamodeld" . It is currently a part of my main bundle and I am referencing it by using the following code. - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel_ != nil) { return managedObjectModel_; } NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"Abcde" ofType:@"momd"]; NSURL *modelURL = [NSURL fileURLWithPath:modelPath]; managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; return

Preventing a CoreData crash for upgrading users

强颜欢笑 提交于 2019-12-08 04:11:23
问题 I built an app about a year and a half ago that I'm coming back to. It was the project I cut my Swift teeth on and obviously a lot has changed since then, both in the language and my Swift abilities. Yesterday for the first time, I updated my single CoreData model to add an optional string attribute. I did the file generation bit and made sure in the inspector column the new data model is appropriately selected. On my Simulator and testing devices, I need to delete the old version of the app

Missing Mapping Model after editing the model

狂风中的少年 提交于 2019-12-08 02:18:18
问题 I'm in the process of a manual core data migration and keep running into Cocoa Error 134140: NSMigrationMissingMappingModelError. I've noticed this happens any time I make any change to the model, even something as small as marking a property as optional. So far, the only solution I've found when this happens is to delete my mapping model and create a new mapping model. Are there any better, less tedious solutions? 回答1: There's a menu option to resolve this. If you update your model anytime

Core Data lightweight migration crash

我与影子孤独终老i 提交于 2019-12-07 18:36:39
问题 I updating my database with a lightweight migration. If I do the update on my device through xcode in debug mode everything runs fine. If I load the app through iTunes as a archive file it will crash before loading the rootViewController. This only happens with my large test database >100mb. I don't get anything useful in the crash log and am not sure what to do with this. His is the only relevant line I can find in the crash log. Unknown thread crashed with unknown flavor: 5, state_count: 1

Renaming coredata .xcdatamodeld file and migration

好久不见. 提交于 2019-12-06 18:30:01
问题 We had a 2 separated apps that we have merged to 2 targets in the same workspace. Both had their core data model ( app1.xcdatamodeld and app2.xcdatamodeld ). Now that both are in the same workspace there is no need for 2 models as they are 99% similar. So I want to change the name of the .xcdatamodeld package to allApps.xcdatamodeld . I was able to rename it but I do not find any reference about the behaviour of migration when doing so. This is the error - 2015-07-28 09:04:06.079 AppName