ios - 具有不成功状态代码的 RestKit 映射

标签 ios mapping restkit-0.20

我正在尝试将 403 禁止响应映射到自定义对象。我用如下响应代码注册了一个映射:

RKResponseDescriptor* tacResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:termsAndConditionMapping pathPattern:@"user" keyPath:nil statusCodes:[NSIndexSet indexSetWithIndex:403]];
[objectManager addResponseDescriptor:tacResponseDescriptor];

但是当 403 响应从服务器发送时,我只是从 RestKit 收到“遇到非成功状态代码:使用 nil 目标对象执行映射”日志并在操作的 mappingResult 属性为 nil 的情况下执行失败 block 。我在这里做错了什么?我需要将特定路径的一个特定错误案例映射到特定对象。

最好的问候, 迈克尔

最佳答案

我不完全确定你的意思,但如果你最终进入失败 block ,则没有 mappingResult 属性。但是可以发现错误隐藏在operation属性中:

[[[operation.error userInfo] objectForKey: RKObjectMapperErrorObjectsKey] firstObject];

关于ios - 具有不成功状态代码的 RestKit 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16893497/

相关文章:

ios - iOS PhoneGap jQuery 移动应用程序中的可见滚动条

ios - 使用 MKLocalSearchCompleter 没有地标

ios - Restkit 失败 : getting access to the json returned

ios - 使用 Restkit MainQueueManagedObjectContext 的奇怪崩溃 - EXC_BAD_ACCESS

ios - RestKit对象映射问题

ios - React Native SVG - (iOS) 不变违规 : Native component for "RNSVGSvgView" does not exist

iphone - 旋转固定位置的 UILabel

c++ - 我可以通过类型访问 "component"吗?

javascript - QGIS - 创建使用实时数据的 map

java - 我可以在 hibernate 中使用相对路径指示映射文件吗?