gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:03:28 26 4
gpt4 key购买 nike

我有一个核心数据模型,其中一个属性当前设置为整数 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, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\";\n note = \"(<NSAttributeDescription: 0xf694220>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities (null), userInfo {\n}, versionHashModifier (null)";
Medicine = "(<NSEntityDescription: 0xf694810>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\n active = \"(<NSAttributeDescription: 0xf694270>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\";\n dose = \"(<NSAttributeDescription: 0xf6942c0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n hoursBetween = \"(<NSAttributeDescription: 0xf694310>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\";\n logs = \"(<NSRelationshipDescription: 0xf694470>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\";\n name = \"(<NSAttributeDescription: 0xf694360>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities (null), userInfo {\n \"com.apple.syncservices.Syncable\" = NO;\n}, versionHashModifier (null)"; }, fetch request templates { }, sourceModel=(<NSManagedObjectModel: 0x2adbb0>) isEditable 1, entities {
Log = "(<NSEntityDescription: 0x2ac700>) name Log, managedObjectClassName Log, renamingIdentifier Log, isAbstract 0, superentity name (null), properties {\n date = \"(<NSAttributeDescription: 0x294ac0>), 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: 0x294a60>), name medicine, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\";\n note = \"(<NSAttributeDescription: 0x2ac810>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities {\n}, userInfo {\n}, versionHashModifier (null)";
Medicine = "(<NSEntityDescription: 0x294b10>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\n active = \"(<NSAttributeDescription: 0x2adaa0>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\";\n dose = \"(<NSAttributeDescription: 0x2adaf0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\";\n hoursBetween = \"(<NSAttributeDescription: 0x2adb40>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\";\n logs = \"(<NSRelationshipDescription: 0x2ada40>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\";\n name = \"(<NSAttributeDescription: 0x2ad9f0>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities {\n}, userInfo {\n \"com.apple.syncservices.Syncable\" = NO;\n}, versionHashModifier (null)"; }, fetch request templates { }, 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, 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, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\\\";\\n note = \\\"(<NSAttributeDescription: 0xf694220>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities (null), userInfo {\\n}, versionHashModifier (null)\";\n Medicine = \"(<NSEntityDescription: 0xf694810>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\\n active = \\\"(<NSAttributeDescription: 0xf694270>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\\\";\\n dose = \\\"(<NSAttributeDescription: 0xf6942c0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n hoursBetween = \\\"(<NSAttributeDescription: 0xf694310>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\\\";\\n logs = \\\"(<NSRelationshipDescription: 0xf694470>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\\\";\\n name = \\\"(<NSAttributeDescription: 0xf694360>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n \\\\\\\"com.apple.syncservices.Syncable\\\\\\\" = NO;\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities (null), 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, managedObjectClassName Log, renamingIdentifier Log, isAbstract 0, superentity name (null), properties {\\n date = \\\"(<NSAttributeDescription: 0x294ac0>), 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: 0x294a60>), name medicine, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\\\";\\n note = \\\"(<NSAttributeDescription: 0x2ac810>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities {\\n}, userInfo {\\n}, versionHashModifier (null)\";\n Medicine = \"(<NSEntityDescription: 0x294b10>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\\n active = \\\"(<NSAttributeDescription: 0x2adaa0>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\\\";\\n dose = \\\"(<NSAttributeDescription: 0x2adaf0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\\\";\\n hoursBetween = \\\"(<NSAttributeDescription: 0x2adb40>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\\\";\\n logs = \\\"(<NSRelationshipDescription: 0x2ada40>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\\\";\\n name = \\\"(<NSAttributeDescription: 0x2ad9f0>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n \\\\\\\"com.apple.syncservices.Syncable\\\\\\\" = NO;\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities {\\n}, userInfo {\\n \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, versionHashModifier (null)\";\n}, fetch request templates {\n}"; }

最佳答案

您将现有的 SQL 或任何持久存储连同表示相关属性具有特定名称和类型的新模式一起交给 Core Data。当 Core Data 查看存储时,它发现存储的格式不适合当前模式。这会导致它抛出您看到的错误。

如果您尚未发布该应用程序,则只需删除您当前的存储空间(如果您使用的是 iOS,请删除该应用程序)并重新启动。一切都应该没问题。

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

基于浏览,this看起来是不错的信息。

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

关于ios - 为什么我在将 Core Data 属性从 Integer 16 更改为 String 时会看到此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11419677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com