ios – 为什么在将Core Data属性从Integer 16更改为String时会看到此错误?

ios – 为什么在将Core Data属性从Integer 16更改为String时会看到此错误?,第1张

概述我有一个Core Data模型,其中一个属性当前设置为Integer 16.我现在想要更改属性名称并更改其类型,但保留当前数据.我已将名称更改排序,并且它正在运行而没有问题. 在尝试更改数据类型时,我得到以下非常长的错误,我该怎么做才能解决它? 2012-07-10 19:33:06.298 Medicine Tracker[5170:707] Unresolved error Error Dom 我有一个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 amountToTake,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时会看到此错误?所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1078302.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存