在每次测试之前,我都会尝试删除数据并重新创建固定装置。应用程序每次点击 MR_saveToPersistentStoreAndWait
时都会崩溃,但是 cannot find data for a temporary oid
[A MR_truncateAll];
[B MR_truncateAll];
[C MR_truncateAll];
[[FixtureLoader instance] loadDataInContext:[NSManagedObjectContext MR_defaultContext]];
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];
为什么会这样?
最佳答案
与其在测试中截断,不如使用内存存储并在每次测试后转储该存储。您不会遇到崩溃,而且速度会快得多。
- (void)setUp {
[super setUp];
[MagicalRecord cleanUp];
[MagicalRecord setupCoreDataStackWithInMemoryStore];
}
关于ios - MagicalRecord 几个截断, "then cannot find data for a temporary oid",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27118016/