为什么Restkit没有正确解析?
我的代表致电:
- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObject:(id)object {
NSString *s = [[NSString alloc] initWithData:objectLoader.response.body encoding:NSUTF8StringEncoding];
RKObjectMapping *rm = objectLoader.objectMapping;
NSLog(@"%@",s);
NSLog(@"%@",rm);
NSLog(@"%@", object);
}
这里输出
{"device_id": "4f75c887e45b583e4f000004"}
RKObjectMapping class => ETDevice: keyPath mappings => (
"RKObjectKeyPathMapping: device_token => secret",
"RKObjectKeyPathMapping: deivce_id => identifier"
)
(null)
任何原因导致它不起作用? 我认为这不是我提出http请求的方式的问题,但无论如何这里是代码:
RKObjectManager *objectManager = [RKObjectManager sharedManager];
[objectManager sendObject:device delegate:self block:^(RKObjectLoader *loader) {
loader.serializationMapping = [[ETDevice objectMapper] inverseMapping];
loader.method = RKRequestMethodPOST;
loader.resourcePath = @"/devices/init";
loader.serializationMIMEType = @"application/json";
loader.objectMapping = [ETDevice objectMapper];
}];
btw我也尝试过:
{"device_id": "4f75c887e45b583e4f000004"}
{devices: {"device_id": "4f75c887e45b583e4f000004"}}
{devices: [{"device_id": "4f75c887e45b583e4f000004"}]}
请帮助,我使用restkit进行时间安排; P
答案 0 :(得分:4)
好的,我为此完全疯了。我在Restkit中调试了几乎所有的堆栈。 这个bug只是: “deivce_id”而不是“device_id”。
我至少了解了很多关于restKit的知识