在新数据模型版本中向现有实体添加新属性时,核心数据崩溃

问题描述 投票:0回答:1

我创建了一个新的数据模型版本并将其设置为当前版本,然后向现有实体添加了一个新属性。之后,当我运行代码时,它在

addPersistentStoreWithType
上崩溃,只有我可以从崩溃中找到
Thread 1: EXC_BAD_ACCESS (code=1, address=0x424531f70)

下面是我遇到崩溃的代码。

+ (NSPersistentStoreCoordinator *)coordinator:(NSPersistentStoreCoordinator *)coordinator byAddingStoreAtURL:(NSURL *)url configuration:(NSString *)configuration options:(NSDictionary *)options error:(NSError * __autoreleasing*)error {
    if (!coordinator) {
        return nil;
    }
    
    NSError *error1 = nil;
    [coordinator addPersistentStoreWithType:EncryptedStoreType configuration:configuration URL:url options:options error:&error1];
    if (error1) {
        NSLog(@"[ERROR] Problems to initialize persistent store coordinator: %@, %@", error1, [error1 localizedDescription]);
    }
    
    return coordinator;
}

这似乎是崩溃发生在

addPersistentStoreWithType

这是崩溃时的堆栈:

如果我删除新添加的属性,那么它运行新创建的数据模型不会出现任何问题。

有什么提示为什么会失败吗?任何想法将不胜感激。

ios objective-c core-data-migration
1个回答
0
投票

我发现了问题,问题出在 EncryptedCoreData 库内,同时迁移包含关系的表,我已修复库内的问题

© www.soinside.com 2019 - 2024. All rights reserved.