HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 为什么在将Core Data属性从Integer 16更改为String时会看到此错误?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个Core Data模型,其中一个属性当前设置为Integer 16.我现在想要更改属性名称并更改其类型,但保留当前数据.我已将名称更改排序,并且它正在运行而没有问题.

在尝试更改数据类型时,我得到以下非常长的错误,我该怎么做才能解决它?

2012-07-10 19:33:06.298 MeDicine Tracker[5170:707] Unresolved error Error Domain=NSCocoaErrorDomain Code=134140 "The operation Couldn’t be completed. (Cocoa error 134140.)" UserInfo=0x2ae140 {reason=Can't find or automatically infer mapping model for migration,desTinationModel=(<NsmanagedObjectModel: 0xf694e20>) isEditable 0,entities {
Log = "(<NSEntityDescription: 0xf6947b0>) name Log,managedObjectClassName Log,renamingIdentifier Log,isAbstract 0,superentity name (null),properties {\n    date = \"(<NSAttributeDescription: 0xf6941d0>),name date,isOptional 1,isTransient 0,entity Log,renamingIdentifier date,validation preDicates (\\n),warnings (\\n),versionHashModifier (null)\\n userInfo {\\n},attributeType 900,attributeValueClassName NSDate,DefaultValue (null)\";\n    meDicine = \"(<NSRelationshipDescription: 0xf694410>),name meDicine,renamingIdentifier meDicine,desTination entity MeDicine,inverseRelationship logs,minCount 1,maxCount 1,isordered 0,deleteRule 1\";\n    note = \"(<NSAttributeDescription: 0xf694220>),name note,renamingIdentifier note,attributeType 700,attributeValueClassName NSString,DefaultValue (null)\";\n},subentities (null),userInfo {\n},versionHashModifier (null)";
MeDicine = "(<NSEntityDescription: 0xf694810>) name MeDicine,managedObjectClassName MeDicine,renamingIdentifier MeDicine,properties {\n    active = \"(<NSAttributeDescription: 0xf694270>),name active,entity MeDicine,renamingIdentifier active,attributeType 800,attributeValueClassName NSnumber,DefaultValue (null)\";\n    dose = \"(<NSAttributeDescription: 0xf6942c0>),name dose,renamingIdentifier amount@R_926_10586@ke,DefaultValue (null)\";\n    hoursbetween = \"(<NSAttributeDescription: 0xf694310>),name hoursbetween,renamingIdentifier hoursbetween,attributeType 100,DefaultValue 0\";\n    logs = \"(<NSRelationshipDescription: 0xf694470>),name logs,renamingIdentifier logs,desTination entity Log,inverseRelationship meDicine,minCount 0,maxCount 0,deleteRule 1\";\n    name = \"(<NSAttributeDescription: 0xf694360>),name name,renamingIdentifier name,versionHashModifier (null)\\n userInfo {\\n    \\\"com.apple.syncservices.Syncable\\\" = NO;\\n},userInfo {\n    \"com.apple.syncservices.Syncable\" = NO;\n},versionHashModifier (null)"; },fetch request templates { },sourceModel=(<NsmanagedObjectModel: 0x2adbb0>) isEditable 1,entities {
Log = "(<NSEntityDescription: 0x2ac700>) name Log,properties {\n    date = \"(<NSAttributeDescription: 0x294ac0>),DefaultValue (null)\";\n    meDicine = \"(<NSRelationshipDescription: 0x294a60>),deleteRule 1\";\n    note = \"(<NSAttributeDescription: 0x2ac810>),subentities {\n},versionHashModifier (null)";
MeDicine = "(<NSEntityDescription: 0x294b10>) name MeDicine,properties {\n    active = \"(<NSAttributeDescription: 0x2adaa0>),DefaultValue (null)\";\n    dose = \"(<NSAttributeDescription: 0x2adaf0>),DefaultValue 0\";\n    hoursbetween = \"(<NSAttributeDescription: 0x2adb40>),DefaultValue 0\";\n    logs = \"(<NSRelationshipDescription: 0x2ada40>),deleteRule 1\";\n    name = \"(<NSAttributeDescription: 0x2ad9f0>),NSUnderlyingError=0x2b0140 "The operation Couldn’t be completed. (Cocoa error 134190.)"},{
NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134190 \"The operation Couldn\U2019t be completed. (Cocoa error 134190.)\" UserInfo=0x2b0160 {reason=source and desTination attribute types are incompatible,entity=MeDicine,property=dosE}";
desTinationModel = "(<NsmanagedObjectModel: 0xf694e20>) isEditable 0,entities {\n    Log = \"(<NSEntityDescription: 0xf6947b0>) name Log,properties {\\n    date = \\\"(<NSAttributeDescription: 0xf6941d0>),validation preDicates (\\\\n),warnings (\\\\n),versionHashModifier (null)\\\\n userInfo {\\\\n},DefaultValue (null)\\\";\\n    meDicine = \\\"(<NSRelationshipDescription: 0xf694410>),deleteRule 1\\\";\\n    note = \\\"(<NSAttributeDescription: 0xf694220>),DefaultValue (null)\\\";\\n},userInfo {\\n},versionHashModifier (null)\";\n    MeDicine = \"(<NSEntityDescription: 0xf694810>) name MeDicine,properties {\\n    active = \\\"(<NSAttributeDescription: 0xf694270>),DefaultValue (null)\\\";\\n    dose = \\\"(<NSAttributeDescription: 0xf6942c0>),DefaultValue (null)\\\";\\n    hoursbetween = \\\"(<NSAttributeDescription: 0xf694310>),DefaultValue 0\\\";\\n    logs = \\\"(<NSRelationshipDescription: 0xf694470>),deleteRule 1\\\";\\n    name = \\\"(<NSAttributeDescription: 0xf694360>),versionHashModifier (null)\\\\n userInfo {\\\\n    \\\\\\\"com.apple.syncservices.Syncable\\\\\\\" = NO;\\\\n},userInfo {\\n    \\\"com.apple.syncservices.Syncable\\\" = NO;\\n},versionHashModifier (null)\";\n},fetch request templates {\n}";
reason = "Can't find or automatically infer mapping model for migration";
sourceModel = "(<NsmanagedObjectModel: 0x2adbb0>) isEditable 1,entities {\n    Log = \"(<NSEntityDescription: 0x2ac700>) name Log,properties {\\n    date = \\\"(<NSAttributeDescription: 0x294ac0>),DefaultValue (null)\\\";\\n    meDicine = \\\"(<NSRelationshipDescription: 0x294a60>),deleteRule 1\\\";\\n    note = \\\"(<NSAttributeDescription: 0x2ac810>),subentities {\\n},versionHashModifier (null)\";\n    MeDicine = \"(<NSEntityDescription: 0x294b10>) name MeDicine,properties {\\n    active = \\\"(<NSAttributeDescription: 0x2adaa0>),DefaultValue (null)\\\";\\n    dose = \\\"(<NSAttributeDescription: 0x2adaf0>),DefaultValue 0\\\";\\n    hoursbetween = \\\"(<NSAttributeDescription: 0x2adb40>),DefaultValue 0\\\";\\n    logs = \\\"(<NSRelationshipDescription: 0x2ada40>),deleteRule 1\\\";\\n    name = \\\"(<NSAttributeDescription: 0x2ad9f0>),fetch request templates {\n}"; }

解决方法

您将现有的sql或任何持久性存储交给Core Data以及表示相关属性具有特定名称和类型的新架构.然后,当Core Data查看商店时,它会发现商店的格式与当前架构的格式不同.这导致它抛出你所看到的错误.

如果您尚未发布应用程序,则只需删除当前存储空间(如果您正在使用iOS,则删除该应用程序)并再次启动.一切都应该没问题.

如果您确实需要执行迁移 – 例如如果已经部署了旧模式 – 那么你显然需要虑迁移.

基于浏览,this看起来很好的信息.

您最终将在项目中使用两个版本的模式,并为Core Data提供足够的信息以在它们之间进行映射.如果您只是在谈论字段重命名,那么您只需使用模式即可实现(在选属性并且您单击时,在Xcode的右侧实用程序窗格中查看“版本控制”下的“重命名ID”字段)查看数据模型检查器,最右边的选项卡)但我不确定是否可以强制类型.如果它不能,那么你还会得到一个映射模型,你可以在xcode中编辑的另一个图形化的东西,绝对可以强制.

大佬总结

以上是大佬教程为你收集整理的ios – 为什么在将Core Data属性从Integer 16更改为String时会看到此错误?全部内容,希望文章能够帮你解决ios – 为什么在将Core Data属性从Integer 16更改为String时会看到此错误?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。