2015-02-10 167 views
0

我在我的应用程序中使用了线数据,它已经上传并且在应用程序商店中运行。现在,我要上传与核心数据,但应用程序的一些变化的新版本与下面的错误而崩溃 -核心数据迁移问题 - 它使应用程序崩溃

reason = "Can't find model for source store"; 

我的代码已经有原子迁移这里是代码

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: 
         [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, 
         [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 

NSError *error = nil; 
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
           initWithManagedObjectModel:[self managedObjectModel]]; 

if(![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
               configuration:nil URL:storeUrl options:options error:&error]) 

我读了苹果文档并尝试使用

- (BOOL)migrateStore:(NSURL *)storeURL toVersionTwoStore:(NSURL *)dstStoreURL error:(NSError **)outError 

但是,我如何在此找到目的地和源StoreURL?我应该从哪里调用这个方法?如何?

请给出一些建议来解决这个问题。

+1

你创建目标模型(从源模型派生)?似乎模型没有正确标记。 FYR - http://code.tutsplus.com/tutorials/core-data-from-scratch-migrations--cms-21844 – Ganapathy 2015-02-10 06:48:43

+0

太棒了....完美的工作...教程很好,并帮助解决了问题相同。谢谢Ganapathy .. :) – RJ168 2015-02-10 07:55:43

回答