[英]Couldn't create mapping policy for class named (Cocoa error 134110)
I am doing a manual/heavy migration in Core Data. 我在Core Data中进行手动/大量迁移。 I have data models ie
myApp2.xcdatamodel
and myApp3.xcdatamodel
. 我有数据模型,即
myApp2.xcdatamodel
和myApp3.xcdatamodel
。
myApp3
has one new table (like junction table) in between two tables both of them were in TO-MANY
relationship. myApp3
在两个表之间有一个新表(如联结表),它们都处于TO-MANY
关系。
Moreover I have defined a NSEntityMigrationPolicy
. 此外,我已经定义了一个
NSEntityMigrationPolicy
。 Now when I run with this custom policy (which was particularly written for relationship and manage the data) I get this error specifically when calling migrationManager.migrateStoreFromURL
现在,当我运行此自定义策略(特别是为关系编写并管理数据)时,我在调用
migrationManager.migrateStoreFromURL
时会特别出现此错误
Optional("Error Domain=NSCocoaErrorDomain Code=134110 \"The operation couldn’t be completed. (Cocoa error 134110.)\" UserInfo=0x7feda0d825b0 {NSUnderlyingException=Couldn\'t create mapping policy for class named (MyTableToMyTablePolicy)}")
I have tried to look on this error but from one way or another it targets Policy class, which I have pasted below. 我试图查看此错误,但从某种方式来看,它的目标是我在下面粘贴的Policy类。
class MyTableToMyTablePolicy: NSEntityMigrationPolicy {
override func createDestinationInstancesForSourceInstance(sourceInstance: NSManagedObject, entityMapping mapping: NSEntityMapping, manager: NSMigrationManager, error: NSErrorPointer) -> Bool {
let sourceKeys:[AnyObject] = sourceInstance.entity.attributesByName.keys.array
let sourceValues = sourceInstance.dictionaryWithValuesForKeys(sourceKeys)
let destinationInstance:NSManagedObject = NSEntityDescription.insertNewObjectForEntityForName(mapping.destinationEntityName!, inManagedObjectContext: manager.destinationContext) as NSManagedObject
let destinationKeys = destinationInstance.entity.attributesByName.keys.array as [AnyObject]
if mapping.userInfo!["modelVersion"]!.integerValue == 2 {
for key in destinationKeys {
let value:AnyObject = sourceValues[key as String]!
if value.hasText() {
destinationInstance.setValue(value, forKey: key as String)
}
}
}
else { // call the super just
super.createDestinationInstancesForSourceInstance(sourceInstance, entityMapping: mapping, manager: manager, error: error)
}
manager.associateSourceInstance(sourceInstance, withDestinationInstance: destinationInstance, forEntityMapping: mapping)
return true
}
}
And following are the xcdatamodels myApp2 and myApp3 respectively: 以下是xcdatamodels myApp2和myApp3:
UPDATED: Crash Log: 更新:崩溃日志:
First, 第一,
Doing a heavy migration on iOS is a bad idea (tm). 在iOS上进行大量迁移是一个坏主意 (tm)。 Heavy migration was not meant to be run on a device with limited CPU, limited memory and limited launch time.
重型迁移并不意味着在CPU有限,内存有限和启动时间有限的设备上运行。
Second, 第二,
You are probably only showing part of the error. 您可能只显示部分错误。 Can you show the entire error stack?
你能展示整个错误堆栈吗? Usually Core Data errors contain internal errors that you can print out via accessing the
-userInfo
dictionary. 通常,Core Data错误包含可以通过访问
-userInfo
字典打印出来的内部错误。 That will give us a deeper understanding of the error. 这将使我们更深入地了解错误。
Last, 持续,
Where is the debugger breaking at? 调试器在哪里突破? What line is throwing the error?
什么行抛出错误?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.