使用“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];
答案 0 :(得分:1)
问题是pathPattern:nil
,因为这意味着每个响应都会考虑所有响应描述符。这导致在许多情况下创建空对象。
要修复,请为每个响应描述符添加路径模式,以便RestKit可以告诉它应该使用哪个。