迁移期间核心数据无法找到源存储

时间:2015-08-25 18:07:52

标签: objective-c core-data

我的所有模型都在一个模式中,它们都是单独版本化的。我正在使用一个映射模型,将属性类型从NSString更改为Double。通过执行以下$source.identifier.doubleValue

enter image description here

然而,我仍然收到以下错误:reason = "Can't find model for source store";Here是指向Gist的完整错误链接。

以下是创建persistentStore的代码(仅作为示例的storeURL):

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        __block BOOL exceptionOccured = NO;
            NSError *dbError = nil;

            NSDictionary *sqlPragmaOptions = @{
                                               @"synchronous" : @"0",
                                               @"journal_mode" : @"TRUNCATE",
                                               };
            //@"fullfsync" : @"0"};
            NSDictionary *options = @{
                                      NSMigratePersistentStoresAutomaticallyOption : @YES,
                                      NSInferMappingModelAutomaticallyOption : @YES,
                                      NSSQLitePragmasOption : sqlPragmaOptions
                                      };
        NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSURL *storeURL = [NSURL fileURLWithPath:[docsDirectory stringByAppendingPathComponent:[self fijiDBName]]];
            if(![_persistantStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                               configuration:nil
                                                         URL:[self storeURL]
                                                     options:options
                                                                  error:&dbError]){
                NSLog(@"ERROR initializing shared Coordinator: %@, %@", [dbError localizedDescription], [dbError localizedDescription]);
#ifdef DEBUG
                abort();
#endif
            }

以下是我的ManagedObjectModel的创建方式:

-(NSManagedObjectModel *)managedObjectModel{
    if (_mom != nil){
        return _mom;
    }

    _mom = [NSManagedObjectModel mergedModelFromBundles:nil];
    NSAssert(_mom, @"%@, %@ NO Model to generate", [self class], NSStringFromSelector(_cmd));
    return _mom;
}

0 个答案:

没有答案