【问题标题】:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“*** setObjectForKey: key cannot be nil”
【发布时间】:2015-07-27 22:53:49
【问题描述】:
    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 ..its printing nil 的值时。谁能帮我解决这个错误或替代解决方案是什么?

【问题讨论】:

  • mappingsByKeyPath = { details = "<0x7ff8d4c42760 objectclass="(null)" propertymappings="(\n" defaultcurrency="">

标签: ios swift mapping restkit


【解决方案1】:

当您使用RKEntityMapping 时,您使用的是entity,而不是objectClass,因此查询它通常不是很有用。也就是说,它必须存在,否则调用mappingForEntityForName:inManagedObjectStore: 时会出现异常。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-16
    • 1970-01-01
    • 2018-04-05
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 2021-09-17
    • 2012-07-12
    相关资源
    最近更新 更多