简体   繁体   English

iOS核心数据未执行轻量级迁移

[英]iOS Core Data not performing Lightweight Migration

I have a model with two entities, let's say A and B . 我有一个包含两个实体的模型,假设AB The model is loaded from sqlite file downloaded from the internet (conforming to Core Data's sqlite format; ie Tables and columns beginning with 'Z'). 该模型是从从互联网下载的sqlite文件加载的(符合Core Data的sqlite格式;即以“ Z”开头的表和列)。

I added a new version for my model; 我为模型添加了新版本; introducing a non-optional integer attribute with default value of zero to the entity B . 向实体B引入默认值为零的非可选整数属性。 For some reason, whenever I query that entity, I get nil result, and an error object of no such column ZVERSION ( version is the new attribute name), even if I'm not using version in my query. 由于某种原因,每当我查询该实体时,都会得到nil结果,并且no such column ZVERSION的错误对象( version是新的属性名称),即使我在查询中未使用version

What probably can be wrong? 可能是什么错?

You can have a attributes named 'version' - it is reserved. 您可以拥有一个名为“版本”的属性-它是保留的。 From apple's docs: 从苹果的文档:

Note that a property name cannot be the same as any no-parameter method name of NSObject or NSManagedObject. 请注意,属性名称不能与NSObject或NSManagedObject的任何无参数方法名称相同。 For example, you cannot give a property the name "description". 例如,您不能为属性指定名称“ description”。 There are hundreds of methods on NSObject which may conflict with property names—and this list can grow without warning from frameworks or other libraries. NSObject上有数百种可能与属性名称冲突的方法,并且该列表可以不断增长,而不会受到框架或其他库的警告。 You should avoid very general words (like "font”, and “color”) and words or phrases which overlap with Cocoa paradigms (such as “isEditing” and “objectSpecifier”). 您应该避免使用非常笼统的单词(例如“ font”和“ color”)以及与可可范例重叠的单词或短语(例如“ isEditing”和“ objectSpecifier”)。

(source: https://developer.apple.com/reference/coredata/nspropertydescription ) (来源: https : //developer.apple.com/reference/coredata/nspropertydescription

'version' is a class method of NSObject used in archiving: https://developer.apple.com/reference/objectivec/nsobject/1415151-version 'version'是用于归档的NSObject的类方法: https : //developer.apple.com/reference/objectivec/nsobject/1415151-version

Also creating an SQL file outside of core data and importing it is not supported. 另外,不支持在核心数据之外创建SQL文件并将其导入。 Apple does not publish it's sqlite format and you may not be conforming it. Apple不会发布其sqlite格式,您可能不符合该格式。 Perhaps Apple has some ZVERION column that you are unaware of. 也许苹果有一些您不知道的ZVERION专栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM