RestKit:如何处理空的response.body? [英] RestKit: How to handle empty response.body?
本文介绍了RestKit:如何处理空的response.body?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用POST请求某些内容,服务器只发送内容长度为0的状态代码200。我怎么处理这个?我不允许在没有映射的情况下添加RKResponseDescriptor,也不允许添加RKResponseDescriptor。
I request something with POST, and the server just sends status-code 200 with a content-length of 0 back. How can I handle this? I'm not allowed to add a RKResponseDescriptor without mapping, nor not add the RKResponseDescriptor.
推荐答案
啊,我刚刚发现,您可以为NSNull类创建映射。这似乎有效。这是代码:
Ah, I just found out, you can create a mapping for the NSNull class. That seems to work. Here's the code:
{
RKObjectMapping* responseMapping = [RKObjectMapping mappingForClass:[NSNull class]];
RKResponseDescriptor* response =
[RKResponseDescriptor responseDescriptorWithMapping:responseMapping
method:RKRequestMethodAny
pathPattern:@"entry/sync"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[restObjectManager addResponseDescriptor:response];
}
请告诉我这是否正确。
这篇关于RestKit:如何处理空的response.body?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文