Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Core data InsertNewObjectForName的异常行为导致NSInternalInconsistencyException_Core Data_Swift - Fatal编程技术网

Core data InsertNewObjectForName的异常行为导致NSInternalInconsistencyException

Core data InsertNewObjectForName的异常行为导致NSInternalInconsistencyException,core-data,swift,Core Data,Swift,我有一个很奇怪的例子,在使用Swift进行实验时,出现了一个核心数据错误。我不确定它是来自Swift(测试错误?)还是我。但是,下面是我的测试用例的设置(在VTModelTests.swift中) 我的错误消息如下所示: 2014-06-22 22:12:25.584 xctest[63792:303] yeah <unknown>:0: error: -[_TtC12VTModelTests12BaseTypeTest testTreeStructure] : failed: ca

我有一个很奇怪的例子,在使用Swift进行实验时,出现了一个核心数据错误。我不确定它是来自Swift(测试错误?)还是我。但是,下面是我的测试用例的设置(在VTModelTests.swift中)

我的错误消息如下所示:

2014-06-22 22:12:25.584 xctest[63792:303] yeah
<unknown>:0: error: -[_TtC12VTModelTests12BaseTypeTest testTreeStructure] : failed: caught "NSInternalInconsistencyException", "+entityForName: could not locate an entity named 'Drawing' in this model."
2014-06-22:12:25.584 xctest[63792:303]是的
:0:错误:-[\u TTC12VTModelTestS12BaseTypeTestTestTreeStructure]:失败:捕获到“NSInternalInconsistencyException”,“+entityForName:在此模型中找不到名为“Drawing”的实体。”
简而言之,我可以“证明”实体名称在那里(日志中的“是”),但核心数据显示了名称不在模型中的问题。以前版本的循环打印出实体,看起来不错。我没有任何第二个版本,并且在打印所有实体时,模型数据中正确显示了新更改的名称(“模型”现在称为“绘图”)。编译后的模型位于结果包中


有人能解释一下吗?还是我必须等待Xcode 6的下一个测试版?我还忽略了什么?非常感谢

我可以确认这个问题。不是答案,但我使用的方法是将insertNewObjectForEntityForName拆分为:

let entity = NSEntityDescription.entityForName("Photo", inManagedObjectContext:context)
let photo = Photo(entity:entity, insertIntoManagedObjectContext:context)
let entity = NSEntityDescription.entityForName("Photo", inManagedObjectContext:context)
let photo = Photo(entity:entity, insertIntoManagedObjectContext:context)