Ios 仅升级属性类型时,Coredata升级失败
我在coredata中使用以下代码进行自动迁移Ios 仅升级属性类型时,Coredata升级失败,ios,core-data,core-data-migration,Ios,Core Data,Core Data Migration,我在coredata中使用以下代码进行自动迁移 NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES],
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
这是实体类的版本1代码
@interface Entity : NSManagedObject
{
}
@property (nonatomic, retain) NSString * var;
@end
下面是版本2代码
@interface Entity : NSManagedObject
{
}
@property (nonatomic, retain) NSDate * var;
@end
在verision中,只有var的属性类型从NSString更改为NSDate
如果只更改了属性类型,请告诉我是否需要执行其他操作
如果我向version2 coredata添加其他类或新属性,它就可以正常工作
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
问候,,
Dhana在Xcode 4.2中实现核心数据模型版本更改时,必须遵循正确的过程。请特别注意:
- 及
在运行新版本之前,它还将有助于从模拟器或您的设备上完全删除应用程序。它是如何失败的?我最近这么做了,效果很好。它发生在我将应用程序从旧版本升级到最新版本时。它发生在我将应用程序从旧版本升级到最新版本时。以下是错误------logsUnresolved error error Domain=NSCOCAerorDomain Code=134140“操作无法完成。(Cocoa错误134140)。”UserInfo=0x7883ae0{reason=无法找到或自动推断迁移的映射模型,destinationModel=()isEditable 0,Entities我正在更改属性类型。即从NSString更改为NSDate。您是否能够在@Dhanaraj解决此问题?我目前正在尝试执行类似的操作,但使用自定义的大量迁移。我已经在appstore中安装了应用程序,因此无法删除旧数据库。更新在所有情况下都有效,但更改数据库除外属性类型。您为什么否决投票?此过程确实确保数据保持完整。您必须编写自己的编码例程才能从字符串转换为日期。