简体   繁体   English

无法为名为的类创建映射策略(Cocoa错误134110)

[英]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.xcdatamodelmyApp3.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:

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.

相关问题 无法创建映射策略 - iOS Core Data - Couldn't create mapping policy - iOS Core Data 可可错误3840无法完成操作 - Cocoa error 3840 The operation couldn’t be completed 该操作无法完成。 (可可错误-1。) - PHPhotoLibrary - The operation couldn’t be completed. (Cocoa error -1.) - PHPhotoLibrary 该操作无法完成。 (可可错误133021.)+迅捷2 - The operation couldn’t be completed. (Cocoa error 133021.) + swift 2 该操作无法完成。 (可可错误1560.) - The operation couldn’t be completed. (Cocoa error 1560.) 无法添加示例示例的可可豆荚文件(使用“ pod lib create”创建)? - Couldn't able to add cocoa pod files (which is created using “pod lib create”) for sample example? 如何解决错误:操作无法完成。 (可可错误3840。)json iOS? - How to resolve error:the operation couldn’t be completed. (cocoa error 3840.) json iOS? 无法保存到数据存储:无法完成操作。 (可可错误133020.) - Failed to save to data store: The operation couldn’t be completed. (Cocoa error 133020.) 该操作无法完成。 (可可错误3840。)”(在字符16周围的对象中没有键值。) - The operation couldn’t be completed. (Cocoa error 3840.)" (No value for key in object around character 16.) checkResourceIsReachableAndReturnError总是返回Domain = NSCocoaErrorDomain Code = 4“操作无法完成。 (可可错误4。)” - checkResourceIsReachableAndReturnError always return Domain=NSCocoaErrorDomain Code=4 “The operation couldn’t be completed. (Cocoa error 4.)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM