由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' *** setObjectForKey:key不能为nil'

时间:2015-05-15 21:47:50

标签: ios swift mapping restkit

    var detailsMapping :RKEntityMapping = RKEntityMapping(forEntityForName:"Details", inManagedObjectStore:managedObjectStore)

    detailsMapping.identificationAttributes = [ "updaterId" ];

    var detailsDictionary = ["productLineDescription" : "productLineDescription","updaterId" : "updaterId","defaultProductId":"defaultProductId","activationType":"activationType","defaultCurrency":"defaultCurrency"]

    detailsMapping.addAttributeMappingsFromDictionary(detailsDictionary)

    println(detailsMapping.objectClass)

当我试图检查detailsMapping.objectClass的值时,打印nil。你能帮我解决一下这个错误或者替代解决方案吗?

1 个答案:

答案 0 :(得分:0)

当您使用RKEntityMapping时,您使用的是entity来创建实例,而不是objectClass,因此查询它通常不是很有用。也就是说,它必须存在,否则当你致电mappingForEntityForName:inManagedObjectStore:时会遇到异常。

这不应该是问题的原因,因为您不应该直接使用objectClass