ios - Restkit 为两个 TableView Controller 获取不同的数据

标签 ios objective-c restkit

使用restkit,我试图获取两个 TableView (收件箱、已发送)的数据, TableView Controller 的功能相同,只是它们引用不同的Web api。 在每个 TableView Controller 中,我根据表配置和初始化restkit,并发出获取 INBOX 或 SENT 数据的请求 一切都很好,但只有一个特定的表,只有首先初始化的表,否则会发生另一个错误

Erestkit.network:RKObjectRequestOperation.m:213 GET 'http://myhost/sent/'(200 OK/0 个对象)[请求=0.9469s 映射=0.0000s 总计=0.9963s]:错误Domain=org.restkit.RestKit.ErrorDomain Code=1001“没有响应描述符与加载的响应匹配。” UserInfo=0x11001a040 {NSLocalizedFailureReason=从 URL 'http://myhost/sent/' 加载了 200 响应,无法匹配所有 (0) 个响应描述符:, NSErrorFailingURLStringKey=http://myhost/sent/, NSErrorFailingURLKey= http://myhost/sent/,NSUnderlyingError=0x11007f790“在搜索的关键路径中找不到可映射的对象表示。”,keyPath=null,NSLocalizedDescription=没有响应描述符与加载的响应匹配。 在我的代码中配置restkit:

// initialize RestKit
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];

NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
objectManager.managedObjectStore = managedObjectStore;

RKEntityMapping *sentMapping = [RKEntityMapping mappingForEntityForName:@"Sent" inManagedObjectStore:managedObjectStore];
sentMapping .identificationAttributes = @[ @"message_id" ];
[sentMapping  addAttributeMappingsFromDictionary:@{
                                                       @"objectId":@"message_id",
                                                       @"ToUserName":@"email_to",
                                                       @"createdAt":@"date_send",
                                                       @"Read":@"read"
                                                       }];
RKResponseDescriptor *responseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:sentMapping
                                             method:RKRequestMethodGET
                                        pathPattern:@"/sent/"
                                            keyPath:@"results"
                                        statusCodes:[NSIndexSet indexSetWithIndex:200]];

[objectManager addResponseDescriptor:responseDescriptor];

我做错了什么?

最佳答案

which failed to match all (0) response descriptors

您尚未配置任何响应描述符,或者至少没有配置与请求 URL 路径模式(大概是 sent/)和方法 (GET) 匹配的响应描述符。

检查描述符注册和过滤条件(路径模式、方法和关键路径)。

关于ios - Restkit 为两个 TableView Controller 获取不同的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24439158/

相关文章:

iphone - 安装 IPA 导致错误 "A signed resource has been added, modified, or deleted"

ios - 以 url 作为属性的 RestKit 映射对象

ios - 为什么第二个 MKPointAnnotation 不显示?

iphone - 用大写字母对 NSArray 进行排序

ios 在通话期间向扬声器发送音频

iphone - iOS:当 iphone 处于 sleep 模式或当我按下主页按钮时执行 NSURLConnection

ios - Restkit 映射字符串数组

iphone - RestKit 请求似乎只工作一次

ios - 如何使UITableView高度动态变化到特定高度,然后在不使用ios中使用AutolayOut的情况下进行滚动

ios - 从 FIREBASE 嵌套的子节点中捕获信息到一个数组中,并将其传递给下一个 ViewController XCODE