【问题标题】:RestKit - Response descriptor not addedRestKit - 未添加响应描述符
【发布时间】:2016-07-15 00:15:31
【问题描述】:

我使用 RestKit 0.26 版并尝试将响应映射到核心数据

这是我用于构建请求和描述符的代码:

    -(void)getProductListProductWithPageNumber: (int) pageNumber managedObjectStore: (RKManagedObjectStore *)managedObjectStore {

    // initialize AFNetworking HTTPClient
    NSURL *baseURL = [NSURL URLWithString:@"https://server.com"];
    AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];

    RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];


    objectManager.managedObjectStore = managedObjectStore;



    RKResponseDescriptor *productListrResponseDescriptor =
    [RKResponseDescriptor responseDescriptorWithMapping:[[CategoricalSystemDownloadManager sharedDownloadManager] getCDProductListProductMapping:managedObjectStore]
                                                 method:RKRequestMethodGET
                                            pathPattern:@"/PLController/plProducts/:"
                                                keyPath:nil
                                            statusCodes:[NSIndexSet indexSetWithIndex:200]];

    [objectManager addResponseDescriptor:productListrResponseDescriptor];

    [objectManager getObjectsAtPath:[NSString stringWithFormat:@"/PLController/plProducts/currentResponseBody-%d", pageNumber]
                         parameters:nil
                            success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {

                            }
                            failure:^(RKObjectRequestOperation *operation, NSError *error) {
                            }];
 }

映射的 JSON 确实是一个数组 -> 键路径 nil,对吗? 它看起来像这样: [ { “产品ID”:240, “品牌标识”:69 } ]

这是错误

 which failed to match all (0) response descriptors

【问题讨论】:

    标签: objective-c restkit restkit-0.20


    【解决方案1】:

    我搞砸了 pathPattern。它应该是 /PLController/plProducts/:currentResponseBody

    【讨论】:

      猜你喜欢
      • 2015-10-29
      • 1970-01-01
      • 1970-01-01
      • 2015-01-18
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      相关资源
      最近更新 更多