Restkit:在所有请求中获取带有“<null>”的映射结果

Restkit : getting mappingResult with "<null>" in all requests

使用 "nil" keyPath 执行 Restkit 请求后工作正常,我得到它的响应:

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

但我仍然在下一个请求的所有映射结果中得到它,如下所示:

"<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];

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

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