RestKit:请求失败时获取HTTP状态代码 [英] RestKit: Getting HTTP status code when a request fails
问题描述
我在iOS应用程序中使用RestKit,我需要对某些HTTP错误代码进行特殊处理。如何在请求中检查响应HTTP状态代码:didFailLoadWithError:
? 用户信息
NSError
字典中是否有一些条目?
I'm using RestKit in an iOS app and I need to have special handling for certain HTTP error codes. How can the the response HTTP status code be checked inside of request:didFailLoadWithError:
? Is there some entry in the userInfo
dictionary of the NSError
?
我在 <$ c中找不到任何内容$ c> RKRequestDelegate 文档。
以下是委托方法的界面:
Here's the interface for the delegate method:
- (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error
推荐答案
对于使用新版RESTkit和objectManager的人,可以从 RKObjectRequestOperation $ c获取状态代码$ c>:
For people using the new version of RESTkit and objectManager, you can fetch the statuscode from the RKObjectRequestOperation
:
operation.HTTPRequestOperation.response.statusCode
这篇关于RestKit:请求失败时获取HTTP状态代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!