Restkit:使用&#34; <null>&#34;获取mappingResult。在所有请求中</null>

时间:2015-02-09 11:58:25

标签: ios mapping restkit

使用“nil”keyPath执行Restkit请求后工作正常,我得到了响应:

"<null>" = "<EstablishmentReservationsMapping: 0x7fc42d1140f0>"

但是我仍然在下一个请求的所有mappingResults中得到它,如下所示:

"<null>" = "<EstablishmentReservationsMapping: 0x7fc42d1140f0>";
"my_establishments" =     (
        "<Establishment: 0x7fc42f89ae10>",
        "<Establishment: 0x7fc42f89b220>",
        "<Establishment: 0x7fc42f89b8f0>",
        "<Establishment: 0x7fc42f90bd10>",
        "<Establishment: 0x7fc42f990d60>",
        "<Establishment: 0x7fc42f93a650>",
        "<Establishment: 0x7fc42f9e6bb0>",
        "<Establishment: 0x7fc42fe9a0a0>",
        "<Establishment: 0x7fc42f9dcbc0>"
    );

我想得到:

"my_establishments" =     (
    "<Establishment: 0x7fc42f89ae10>",
    "<Establishment: 0x7fc42f89b220>",
    "<Establishment: 0x7fc42f89b8f0>",
    "<Establishment: 0x7fc42f90bd10>",
    "<Establishment: 0x7fc42f990d60>",
    "<Establishment: 0x7fc42f93a650>",
    "<Establishment: 0x7fc42f9e6bb0>",
    "<Establishment: 0x7fc42fe9a0a0>",
    "<Establishment: 0x7fc42f9dcbc0>"
);

这是第二个请求的响应responseDescriptor:

RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:establishmentMapping method:RKRequestMethodGET pathPattern:nil keyPath:@"my_establishments" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

[_objectManager addResponseDescriptor:responseDescriptor];

1 个答案:

答案 0 :(得分:1)

问题是pathPattern:nil,因为这意味着每个响应都会考虑所有响应描述符。这导致在许多情况下创建空对象。

要修复,请为每个响应描述符添加路径模式,以便RestKit可以告诉它应该使用哪个。